- Home /
Added custom DLL. Internal Compiler Error
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.
Are you sure your DLL compiled for 3.5 version of .NET Framework?
Ohhhhhhhhh. I believe its 4.0. Also, it uses [DLLImport] to reference kernel32.dll. Could that cause an issue?
I believe [DLLImport] should not be a problem while you targeting your Unity application to Windows. But not tested myself.
Answer by HSMInteractive · Jan 11, 2014 at 10:13 PM
I fixed it. I rebuilt the DLL under the 3.0 framework and it seemed to be good.
Using Unity 5.1 and I only had to lower it to the 3.5 framework to get rid of this error message. In Visual Studio 2013 it can be found under the Project menu, ProjectName Properties, Application (default) tab, Target framework dropdown.
Answer by MrLucid72 · Jan 20, 2016 at 09:28 AM
For me, it was the imported store asset. I deleted the plugins folder and all is well.
Answer by Bunny83 · Jan 11, 2014 at 09:09 PM
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.
Thats what I did. Then in the "References" folder on the left side of $$anonymous$$onoDevelop where all the DLL's are mentioned, I added it there.
You don't have to add it there. When you sync the project it will be updated automatically.
Is it possible that this question isn't about a Unity project? It seems you try to build a .NET / $$anonymous$$ono project and included the UnityEngine.dll. That's not possible at all. The UnityEngine.dll is just an "interface" into the UnityEngine which is written in native code. If it is a Unity project, as i said, you shouldn't change anything in the $$anonymous$$ono project itself. Whenever you add or modify a script, Unity will update the project automatically. If not you have to press "Sync $$anonymous$$onoDevelop Project" to manually update the project.
ps: The UnityEditor.dll only works in the Unity-Editor application. It references native parts of the editor application. That's why UnityEditor.dll can only be used in Editor scripts.
It would help to know what you're actually doing and what you want to achieve
Ok. I made a DLL in Visual Studio. It contains stuff for reading INI files. I added it to my Unity project so my game can also read INI files (config files). I hope that makes sense. I'm only using $$anonymous$$onoDevelop for my Unity game. It has nothing to do with any UnityEngine.dll files and whatever else you mentioned.
I removed the script from my Unity project and was able to build the project. The custom DLL was also exported into the $$anonymous$$anaged folder of my game's data folder. It appears to be an issue with script then.
Now I get the error every time I add a new script.
Answer by valentemesmo · Jun 02, 2015 at 02:34 PM
In my case, I had AndroidJavaObject on a DLL used in All Platforms... I moved all AndroidJavaObject to a Android only DLL... problem solved!
Answer by mateiasu · Jul 27, 2015 at 11:35 AM
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?!
Your answer
Follow this Question
Related Questions
Why can't I build Web Player in Unity while I have no problems with building standalone versions? 2 Answers
Edit asset DLL? 1 Answer
How to use Unity's mono to compile in MonoDevelop 2 Answers
Error building Player: Extracting referenced dlls failed. 8 Answers
How to use an Image(PNG) and GUISkin inside a dll ? 1 Answer