Hi,
I'm trying to do the Coding4Fun Game Devlopment tutorial, but I can't seem to get it to work. I first tried it with the latest DirectX SDK (june 2006). But when I add the references to Mircosoft.DirectX and Microsoft.DirectX.Direct3D the Direct3D is version 1.0.2902.0 and the DirectX is version 2.0.0.0 This results in this error:
The type 'Microsoft.DirectX.Direct3D.Device' exists in both 'c:\WINDOWS\Microsoft.NET\DirectX for Managed Code\1.0.2902.0\Microsoft.DirectX.Direct3D.dll' and 'c:\WINDOWS\Microsoft.NET\DirectX for Managed Code\2.0.0.0_x86\Microsoft.DirectX.dll
Why is the Mircrosoft.DirectX.Direct3D dll a different version then the Microsoft.DirectX dll I would expect to get the latest version of both in the SDK...
Then I tried it using the same DirectX SDK as the writer of the article used (february 2005). Now the code does compile, but I get a runtime error:
System.TypeInitializationException was unhandled
Message="The type-initialisationfunction for Microsoft.DirectX.Direct3D.Manager has caused an exception."
Source="Microsoft.DirectX.Direct3D"
TypeName="Microsoft.DirectX.Direct3D.Manager"
StackTrace:
at Microsoft.DirectX.Direct3D.Manager.get_Adapters()
at BattleTank2005.GameEngine..ctor() in L:\C#_Projects\BattleTank2005\BattleTank2005\GameEngine.cs:line 29
at BattleTank2005.Program.Main() in L:\C#_Projects\BattleTank2005\BattleTank2005\Program.cs:line 17
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
I translated some parts of it from dutch (I have a dutch windows and visual studio).
The little information about this error I did find is that it has to do with different versions of the dll's. When I check in the output window, it says it loads Microsoft.DirectX.dll version 2.0.0.0 Even if I don't reference it...
How can I solve this I prefer to use the latest SDK of course...
Greetings,
El Loco

Problems with Microsoft.DirectX SDK versions
Robert.Altland
lex3
Make sure you only use references to the 1.1 version of Microsoft.DirectX.Direct3D. Remove any references to the beta 2.0 managed directX libraries. The best way to solve this is to remove _all_ references to Managed DirectX assemblies and manually add the proper ones. The error you are seeing is because you have a reference to the 1.1 library and the 2.0 library.
C#Geek
Huseyin Akturk