I’m aware there are a lot of these problems floating around but nothing seemed to fit my situation. I’ve created a custom DLL for use in both a WinForms app and Unity. I added it to the project, added it to the references folder in MonoDevelop and started coding. Everything builds fine with no errors but when I go to build the project, I get this error:
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
Would it have anything to do with my DLL? Do I need to re-write it import it correctly or something? I’m really at a loss here.
I fixed it. I rebuilt the DLL under the 3.0 framework and it seemed to be good.
You shouldn’t modify the Monodevelop project since it is created and updated by Unity. You simply have to copy your DLL into your project, somewhere in your assets folder or subfolder.
In my case, I had AndroidJavaObject on a DLL used in All Platforms…
I moved all AndroidJavaObject to a Android only DLL… problem solved!
I had an Editor and Runtime library put into their appropriate folders ( /Editor
and /Plugins
). Unfortunetly the Editor library was built for target Mono / .net 4.5
. (Why did I not see this in first place? … continue reading … )
IMPORTANT! I’ve suspected & deleted the Runtime library since it was the only thing that I’ve changed and it did work before with the Editor library and Unity3D did say everything ok, even that the error was inside / related to the Editor library!!!
Conclusion: Do you have an Editor dll? Try delete it.
Hindsight: Maybe Unity could throw an appropriate error pointing to the assembly causing the compilation error?!
For me, it was the imported store asset. I deleted the plugins folder and all is well.
I recommend checking Unity log file. In our case it said something like:
The following assembly referenced from
(project path)\Assets\Plugins\AWSSDK.Core.dll
could not be loaded:
Assembly: System.Configuration (assemblyref_index=3)
Version: 2.0.0.0
Public Key: b03f5f7f11d50a3a
Which hinted that it can not find some default libraries, thus switching to full .Net compatibility mode in Player settings solved the problem.