ReflectionTypeLoadException

I have a project which has been working fine until now. When importing packages – such as assets purchased from the asset store – Unity displays an internal compiler error (Unhandled Exception: System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded). The same occurs when simply copying said project files into the Assets folder, but not when creating a new project and importing packages. Thankfully I had a backup copy of my project (which I then copied again for safety); it also works fine on its own, but breaks immediately when certain packages are imported. Apart from AssetStore packages, it even breaks when importing some Unity packages:

Water (Basic): OK

Water (Pro): Internal compiler error

Attempting to narrow the cause further, I have found that the error only occurs (at least with Water(Pro)) when c# scripts are placed in the Assets/Editor folder. Deleting all scripts from there prevented the error, while creating a new c# script in the folder caused the error. Deleting every line of code in said c# script did not change the situation; I had to delete the .cs file itself to remove the error. Further, it seems that if any c# scripts are placed in any /Editor folder, located anywhere in the project (such as Assets/SomeImportedAsset/SomeFolders/Editor), will result in the same error. Javascript files placed in Assets/Editor (or elsewhere) do not cause the error.

Any assistance would be appreciated. I apologize for not providing more information, but that is all I have; the error message is very unclear, and the entire situation is very strange.

i had same problem too
and i exectude Assets>Reimoprt All(maybe you need to backup your project before do this)
then it fix
i do not know the reason
but it work for me

Answering my own question after many hours of testing.

Check .dll’s in the Assets folder. In this case, System.Web was causing the error. None of the System.Web.dll files located on my computer – regardless of version – worked without generating this particular error; I downloaded a copy of System.Web.dll v2.0.50727 x86 off the internet.

As for why the error only occurred when c# scripts were placed in an /Editor folder, Assembly-CSharp-Editor is only created under that condition, and it appears that only that assembly generates the error. Removing the reference to System.Web.dll in the assembly changed nothing. It is unclear as to why this is the case. Perhaps a Unity dev would have more insight.

I must strongly recommend improved error messages/logs for this; if System.Web.dll had been clearly referenced, rather than UnityEditor.Android.Extensions.dll, the error could’ve been resolved within minutes rather than hours. I suspect the same would be true for many other users.

I found the problem for my project when I got this error message was that I was using a DLL built using a .Net 4.5.1 framework. After replacing the offending DLL and then Assets > Reimport All it was fine. The problem is that Mono (the generic multiplatform .Net clone) will only work with .Net up to 3.5.

I was having a similar problem with the same error message. Thanks to the answer above that noted the problem was with the editor folder I found a solution to my problem.

I stripped out all the editor scripts from my original DLL project and created a separate project for them. I then recompiled both projects and put the resulting DLLs into my game’s Asset folder like so:

/Assets/MyDLL/MyDLL.dll
/Assets/MyDLL/Editor/MyDLLEditor.dll

This was indeed a strange problem to track down, as I could run my game just fine from the editor. The error only showed up when I tried to build the game as a standalone player. Hopefully this will help someone else as it appears the error message given applies to more than one kind of problem.

In my case, I had AndroidJavaObject on a DLL used in All Platforms… I moved all AndroidJavaObject to a Android only DLL… problem solved!

For me, it was the imported store asset. I deleted the plugins folder and all is well.

This just happened to me in 5.4 beta, after importing a package from a previous project.

To fix it, I had to go to Edit > Project Settings > Player, then in Inspector > Other Settings > Optimization > then change “API Compatibility Level” to “.Net 2.0” (instead of .Net 2.0 Subset)

I had the same problem, for solved it’s simple…
Just Close unity >> Open Unity … and it’s good you can build :wink:

I had faced a similar problem, but not with an asset store DLL, but with a file written by a colleague. I had rather stumbled upon a very simple solution. I requested my colleague to check the version of .NET he built for and changed it .NET 2.0 from Visual Studio. Turns out he accidentally built it for the latest version of .NET. Changing it .NET 2.0 solved the problem completely.