Reputation: 7618
I spent some hours trying solutions I found online but nothing worked so here's my question for Stackoverflowers.
I made a small plugin for Unity and imported the dll into my project folder. It works fine when I launch the game within 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 did so far:
And by the way, it works fine in Unity Editor so it should be pretty clear that I made it right as I followed the instructions in the official Plugins making guide.
Thanks for any help
Upvotes: 2
Views: 9646
Reputation: 335
The thing I needed to do was change the API compatibility level from .NET Subset 2.0 to .NET 2.0. Suddenly all was fine. Probably the threading task was doing some problems.
Please see reference
Upvotes: 1
Reputation: 11
What worked for me was setting the target platform lower(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/
Upvotes: 1
Reputation: 7618
When I deleted the dll from the Plugins folder while leaving just a copy of it in the project's root folder, it worked.
So in this case the solution is to leave the dll just in the project's root folder and nowhere else.
I'm not sure why though, so part of the question is still open.
Upvotes: 2
Reputation: 14171
For what platform are you trying to compile the script?
If you're doing it for iOS make sure that you don't have any events declared inside the DLL.
I had problems with this and I ended up removing them.
Upvotes: 0