Buenas!
Estoy empezando con MDX y desde el principio me esta dando problemas, sigo los tutoriales de Coding4fun de Microsoft e incluso intento compilar las samples que vienen con el SDK (el de Agosto'05) y en todos los casos me sale el mismo error, al compilar/ejecutar dice que hay un BadImageFormatException en el metodo Main, donde se supone se crean los componentes:
static int Main()
{
System.Windows.Forms.Application.EnableVisualStyles();
using(Framework sampleFramework = new Framework()) <---- Error aqui
{
...
Sabeis a que puede ser?
Copio aqui la excepcion completa:
System.BadImageFormatException was unhandled
Message=" no es una aplicación Win32 válida. (Exception from HRESULT: 0x800700C1)"
Source="mscorlib"
StackTrace:
at System.Reflection.Assembly._nGetEntryPoint()
at System.Reflection.Assembly.get_EntryPoint()
at Microsoft.VisualStudio.HostingProcess.HostProc.GetEntryPointAptThreadState(String assemblyFile)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunParkingWindowThread()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Por si sirve de algo (que nunca se sabe) uso Windows XP x64 con la ultima Beta del VC# y la .NET de 64 bits.
Ni idea. La verdad es que no he probado a compilar nunca los samples...
Bueno, gracias igualmente :D
De todas formas, no podria alguien poner aqui algun codigo de ejemplo (unicamente inicializar la ventana) que funcione para ver si es cosa del .NET64 o de mi pc o de la fase lunar?
Gracias desde ya :D
A este tutorial lo hice hace un tiempo y funciona perfectamente. Es el código dentro de un winform.
Compilado con C# Express Beta 2 y el último SDK de MDX
Pero no es el XP de 64
El link al tuto
Link al Tutorial
using System;
using System.Drawing;
using System.ComponentModel;
using System.Windows.Forms;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
namespace dxtest01
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class cView : System.Windows.Forms.Form
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
// Added a Direct3D device context
private Device device = null;
public cView()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
// Changed Form Style to do all updates in the Paint function
this.SetStyle( ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true );
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
/// <summary>
/// We will initialize our Direct3d graphics device here
/// </summary>
public void InitializeGraphics()
{
// Set our presentation parameters
PresentParameters presentParams = new PresentParameters();
presentParams.Windowed = true;
presentParams.SwapEffect = SwapEffect.Flip;
presentParams.AutoDepthStencilFormat = DepthFormat.D16;
presentParams.EnableAutoDepthStencil = true;
// Create our device
device = new Microsoft.DirectX.Direct3D.Device(0, Microsoft.DirectX.Direct3D.DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, presentParams);
}
private void SetupCamera()
{
device.Transform.Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4, this.Width / this.Height, 1.0f, 1000.00f);
device.Transform.View = Matrix.LookAtLH(
new Vector3(0.0f ,4.0f, 0.0f),
new Vector3(0.0f,-4.0f, 0.0f),
new Vector3(0,1,0));
}
// Render the Direct3D graphics
public void Render()
{
// Clear the Direct3d device and get ready to paint a frame
device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.CornflowerBlue, 1.0f, 0);
// Now set up the view Frustum. This code will eventually move into another location, but for now we'll do it here
SetupCamera();
//Now call Direct3D and let it do its math
device.BeginScene();
// This is where the vector rendering gets done.
device.EndScene();
// Show the contents of the Direct3D device
device.Present();
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
//
// cView
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Name = "cView";
this.Text = "cView";
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
using (cView dxView = new cView())
{
// Initialize Direct3D and show the Form
dxView.InitializeGraphics();
dxView.Show();
// As long as there is a cView, run this loop
while (dxView.Created)
{
dxView.Render();
Application.DoEvents();
}
dxView.Dispose();
}
}
}
}
Suerte!
Muchas gracias por el codigo, pero sigue fallandome :/ Al final he decidido volver al Windows XP "normal", el 64 da demasiados problemas con practicamente todos los otros programas que necesito, o bien directamente no deja instalarlos por no ser compatibles con la nueva arquitectura, o petan por que si, o vayaustéasaber.
En fin, que gracias por todo y continuo bajando drivers y cosillas, luego probare de nuevo con el MDX y ya contare como ha ido :)
Hola!
he encontrado el problema y se como solucionarlo.
si utilizas el vista abre la linea de comando(o DOS) pero asegurate de que habras el programa como Administrador. entonces busca/scribe lo siguiente:
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Ldr64.exe setwow
reciviras un mensaje de que todo salio bien y despues de ahi todo debe de funcionar sin problemas.
Salu2
@ruantec-Man