- Home /
Internal Compiler Error trying to use NSubstitute
Background: I'm very, very, very new to C# and Unity.
I'm trying to use the NSubstitute framework in my project. I have dll and xml files (taken from the library's NET35 directory) in Assets/Plugins. MonoDevelop seems to be happy with it, but the Unity editor gives me an internal compiler 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
The Editor.log file shows a bunch of complaints about being unable to load various System.ComponentModel and Castle classes.
I've looked up solutions for similar problems, and they tend to suggest messing with the .net compatability in player settings, but that didn't seem to help. The log file does seem to suggest that is where the problem lies, however, so maybe I just wasn't messing with the right settings.
Any and all help would be awesome.
the NET35 library's will not work during compiling if possible search for NET2.0 libraries . if they are NET2.0 then only it will work. same situation i faced in my project so it would be helpfull for u
There's a comment on the Unity Test Tools asset store page that strongly suggests someone was able to use NSubstitute with Unity. There's also other places that suggest it's possible to get some .NET 3.5 libraries working, at least in older versions of Unity, such as in this post, so I don't want to give up hope quite yet.
Answer by seppukitty · Jan 25, 2016 at 03:10 PM
If you have the newest version of Unity (5.3+):
Put the NSubstitute files inside a directory named Editor (make one if you don't have one). Also make sure you click on the dll and select "Editor" from the list under "Select platforms for plugin".
You can also download Unity Test Tools and only import NSubstitute, but that's all it does anyway. There is no special NET2.0 library for NSubstitute, so if you need it outside the editor (in your actual game for some reason) then it won't work.