Can't load type from DLL.


I wrote a DLL named “GameInput.dll” that references “DirectInput.dll”. When I put “GameInput.dll” into Unity and add a reference to Visual Studio I gain access to all of the code in “GameInput.dll”. Although I don’t get any errors in Visual Studio when I go back to Unity I am getting a “TypeLoadException: Could not load type from assembly” error. If I go back to “GameInput.dll” and remove all usages of the “Microsoft.DirectX.DirectInput” namespace it removes all errors in Unity. Does anyone know what the problem is?

Thank you

Do you have the dll that contains the “Microsoft.DirectX.DirectInput” namespace in your project as well? Unity doesn’t use the .NET framework. Everything has to be included in your probject. Unity has the core of the Mono framework (mscorlib.dll, System.dll, …) available, but anything that goes beyond need to be placed in the plugins folder of your project, so it will be included in your project.

If you place a DLL into the plugins folder you never have to add a reference manually. Just let Unity re create the csproj file. Unity will add all references automatically.