C# Joystick Detection Error

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.

c#
directx
joystick
asked on Stack Overflow Jan 14, 2010 by Petezah

1 Answer

3

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...)

answered on Stack Overflow Jan 14, 2010 by Reed Copsey

User contributions licensed under CC BY-SA 3.0