- Home /
Editor throws TypeLoadException during build
Hi. I have a project that runs without errors in the editor. But when i try to make a build, it stops compiling at ~15-20% and gives me those errors (horizontal lines are not part of error text, i just thought it would be nice to separate everything visualy):
NullReferenceException: Object reference not set to an instance of an object
UnityEditor.AssemblyTypeInfoGenerator.GetFields (Mono.Cecil.TypeDefinition type, Boolean isGenericInstance, System.Collections.Generic.Dictionary`2 genericInstanceTypeMap) (at C:/BuildAgent/work/d63dfc6385190b60/Editor/Mono/BuildPipeline/AssemblyTypeInfoGenerator.cs:229)
UnityEditor.AssemblyTypeInfoGenerator.AddType (Mono.Cecil.TypeReference typeRef, System.Collections.Generic.Dictionary`2 genericInstanceTypeMap) (at C:/BuildAgent/work/d63dfc6385190b60/Editor/Mono/BuildPipeline/AssemblyTypeInfoGenerator.cs:150)
UnityEditor.AssemblyTypeInfoGenerator.AddBaseType (Mono.Cecil.TypeReference typeRef, System.Collections.Generic.Dictionary`2 genericInstanceTypeMap) (at C:/BuildAgent/work/d63dfc6385190b60/Editor/Mono/BuildPipeline/AssemblyTypeInfoGenerator.cs:209)
UnityEditor.AssemblyTypeInfoGenerator.AddType (Mono.Cecil.TypeReference typeRef, System.Collections.Generic.Dictionary`2 genericInstanceTypeMap) (at C:/BuildAgent/work/d63dfc6385190b60/Editor/Mono/BuildPipeline/AssemblyTypeInfoGenerator.cs:161)
UnityEditor.AssemblyTypeInfoGenerator.GatherClassInfo () (at C:/BuildAgent/work/d63dfc6385190b60/Editor/Mono/BuildPipeline/AssemblyTypeInfoGenerator.cs:302)
UnityEditor.AssemblyHelper.ExtractAssemblyTypeInfo (System.String assemblyPathName) (at C:/BuildAgent/work/d63dfc6385190b60/Editor/Mono/AssemblyHelper.cs:262)
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
Error building Player because scripts had compiler errors
Come on, guys! I get, that not everyone is willing to sacrifice their own time to fix others problems, but a least give me a quick tip: where and what should I google to find the solution? $$anonymous$$ay be it looks like missing dll? Or may be some script that i don't use in my scene, but have in project folder, can mess with compiler logic? What would you check if you had such problem?
which target?
do you get the same errors if you try building for a different target?
Sims like it's same for evrything exept Web:
NullReferenceException: Object reference not set to an instance of an object
UnityEditor.AssemblyTypeInfoGenerator.GetFields ($$anonymous$$ono.Cecil.TypeDefinition type, Boolean isGenericInstance, System.Collections.Generic.Dictionary`2 genericInstanceType$$anonymous$$ap) (at C:/BuildAgent/work/d63dfc6385190b60/Editor/$$anonymous$$ono/BuildPipeline/AssemblyTypeInfoGenerator.cs:229)
UnityEditor.AssemblyTypeInfoGenerator.AddType ($$anonymous$$ono.Cecil.TypeReference typeRef, System.Collections.Generic.Dictionary`2 genericInstanceType$$anonymous$$ap) (at C:/BuildAgent/work/d63dfc6385190b60/Editor/$$anonymous$$ono/BuildPipeline/AssemblyTypeInfoGenerator.cs:150)
UnityEditor.AssemblyTypeInfoGenerator.AddBaseType ($$anonymous$$ono.Cecil.TypeReference typeRef, System.Collections.Generic.Dictionary`2 genericInstanceType$$anonymous$$ap) (at C:/BuildAgent/work/d63dfc6385190b60/Editor/$$anonymous$$ono/BuildPipeline/AssemblyTypeInfoGenerator.cs:209)
UnityEditor.AssemblyTypeInfoGenerator.AddType ($$anonymous$$ono.Cecil.TypeReference typeRef, System.Collections.Generic.Dictionary`2 genericInstanceType$$anonymous$$ap) (at C:/BuildAgent/work/d63dfc6385190b60/Editor/$$anonymous$$ono/BuildPipeline/AssemblyTypeInfoGenerator.cs:161)
UnityEditor.AssemblyTypeInfoGenerator.GatherClassInfo () (at C:/BuildAgent/work/d63dfc6385190b60/Editor/$$anonymous$$ono/BuildPipeline/AssemblyTypeInfoGenerator.cs:302)
UnityEditor.AssemblyHelper.ExtractAssemblyTypeInfo (System.String assemblyPathName) (at C:/BuildAgent/work/d63dfc6385190b60/Editor/$$anonymous$$ono/AssemblyHelper.cs:262)
UnityEditor.HostView:OnGUI()
Internal compiler error. See the console log for more information. output was:
Unhandled Exception: System.TypeLoadException: Could not load type 'System.Runtime.Versioning.TargetFrameworkAttribute' from assembly 'ServiceStack.Text'.
at $$anonymous$$ono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0
at $$anonymous$$ono.CSharp.Driver.$$anonymous$$ain (System.String[] args) [0x00000] in <filename unknown>:0
Error building Player because scripts had compiler errors
Answer by rutter · Jul 29, 2014 at 05:41 PM
All hubbub aside, the compiler is throwing a TypeLoadException
because it's failing to access some class during the build process. This is usually caused by a conflicting name.
Do any of your classes have the same name as some class in Unity?
Are you using any plugins that might have that problem? Especially if you have dll
files in your project. Most reports I saw about this were trying to mix Playmaker and some Kinect plugin, but that doesn't mean it couldn't happen elsewhere.
Yes!!! There was a ServiseStack.Text.dll in my Assets folder. After deleting it, errors were gone! I guess, i didn't notice it when copying files to new project - that's why there everything worked.
Thanks a lot!
I was hitting this error in VS after upgrading my UWP game from 5.6.1 to 2017.2.0b8. In my case I had to reimport Text$$anonymous$$esh Pro package and delete the UWP folder and build again. Thank you for the clue, the error message is super cryptic!
Answer by Zerlingmusic · Jul 29, 2014 at 05:34 PM
Okay it's kinda solved, but is even wierder now. I've mede a new project and copied all the files from this one to mess with them an see what causes the mistake. I tryied to make a build as it is just to be sure to get same mistakes - and everything worked out! The build was complete with no errors! I launched it and it worked as intended. Tried to do same with old project - and got those errors. Tried do do that in new project - everything was working.
I have no problems with finishing the projest in the new folder, but i'm still curious: what could that be?
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
How can I stop the variable values reverting to its default values after being built? 1 Answer
TypeLoadException: System.Security.Authentication.ExtendedProtection.ChannelBinding 1 Answer
Building for iPad 1 Answer
Mono Error when compiling scripts 1 Answer