Unity internal compiler error with custom dll

I spent several hours searching for solutions that I found on the Internet, but nothing worked, so my question is for Stackoverflowers.

I made a small plugin for Unity and imported the dll into my project folder. It works fine when I run the game inside the editor, but if I try to compile, I get the following:

Internal compiler error. See the console log for more information. output was: Unhandled Exception: System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded. at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (bool) at System.Reflection.Assembly.GetTypes () [0x00000] in <filename unknown>:0 at Mono.CSharp.RootNamespace.ComputeNamespaces (System.Reflection.Assembly assembly, System.Type extensionType) [0x00000] in <filename unknown>:0 at Mono.CSharp.RootNamespace.ComputeNamespace (Mono.CSharp.CompilerContext ctx, System.Type extensionType) [0x00000] in <filename unknown>:0 at Mono.CSharp.GlobalRootNamespace.ComputeNamespaces (Mono.CSharp.CompilerContext ctx) [0x00000] in <filename unknown>:0 at Mono.CSharp.Driver.LoadReferences () [0x00000] in <filename unknown>:0 at Mono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0 at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0 

What i have done so far:

  • my dll is located in the "Plugins" folder in "Assets"
  • tried putting the dll (also) at the root of the project
  • with and without spaces
  • install .NET 2.0 in Unity

And by the way, it works great in the Unity editor, so it should be pretty clear that I did everything right, following the instructions in the official plugin guide.

Thanks for any help

+2
source share
4 answers

When I deleted the dll from the Plugins folder, leaving only a copy of it in the root folder of the project, it worked .

So, in this case, the solution is to leave the dll only in the root folder of the project and nowhere else.

I am not sure why, although part of the answer remains open.

+2
source

What worked for me is to set the target platform below (from 4.5 to 3.5). As suggested here: http://forum.unity3d.com/threads/ideas-reflectiontypeloadexception-the-classes-in-the-module-cannot-be-loaded.230389/

+1
source

I needed to change the API compatibility level from .NET Subset 2.0 to .NET 2.0. Suddenly everything was fine. Probably the task of threading made some problems.

See link

+1
source

What platform are you trying to compile the script on?

If you are doing this for iOS, make sure that you do not have events declared inside the DLL.

I had problems with this and I ended up removing them.

0
source

All Articles