views:

302

answers:

1

I'm trying to create an application in C# that uses a joystick. I went to "http://www.codeproject.com/KB/directx/joystick.aspx" and basically copied the example exactly but I keep getting the follow error: "is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)". The application is currently a console app for testing purposes. I used the following includes:

"using Microsoft.DirectX;" "using Microsoft.DirectX.DirectInput;"

and the line of code that throws the error is

DeviceList gameControllerList = Manager.GetDevices(DeviceClass.GameControl,EnumDevicesFlags.AttachedOnly);

Also I'm using Windows 7, not sure if that helps or not.

+1  A: 

If you're using a 64bit Version of Windows 7, make sure to compile your application for x86. Managed DirectX is only supported in 32bit, so if you're compiling targetting 64bit or AnyCPU, it will throw with the error you are receiving.

If you need to support this for 64bit, I recommend converting your code to use SlimDX instead of Managed DirectX. (Personally, I would recommend doing this in any case, as SlimDX is far superior to MDX...)

Reed Copsey