IL2CPP error for type 'System.Int32' in Int32.cs

As the title suggests I’m receiving this error when trying to build for WebGL. I’m Using Unity 5.6.2p3 now as this is the last known version that I managed to get a build for WebGL working for.

Previous to this I had upgraded to 2017.1.0p1 but bugs that effected WebGL only (reported elsewhere but have not had time to do a small project to show the bug just yet) have forced me to downgrade again and now am unable to create any builds for WebGL at all.

The output from the compiler looks like this:

stdout:
IL2CPP error for type 'System.Int32' in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Int32.cs:699
Additional information: Object reference not set to an instance of an object.
il2cpp.exe didn't catch exception: System.NullReferenceException: Object reference not set to an instance of an object.
   at Unity.IL2CPP.MethodBodyWriter.GetMethodCallExpression(MethodReference callingMethod, MethodReference methodToCall, MethodReference unresolvedMethodtoCall, TypeResolver typeResolverForMethodToCall, MethodCallType callType, IRuntimeMetadataAccess runtimeMetadataAccess, VTableBuilder vTableBuilder, IEnumerable`1 argumentArray, Boolean useArrayBoundsCheck, Func`2 addUniqueSuffix)
   at Unity.IL2CPP.MethodBodyWriter.CallExpressionFor(MethodReference callingMethod, MethodReference unresolvedMethodToCall, MethodCallType callType, List`1 poppedValues, Func`2 addUniqueSuffix, Boolean emitNullCheckForInvocation)
   at Unity.IL2CPP.MethodBodyWriter.ProcessInstruction(Node node, InstructionBlock block, Instruction& ins)
   at Unity.IL2CPP.MethodBodyWriter.GenerateCodeRecursive(Node node)
   at Unity.IL2CPP.MethodBodyWriter.Generate()
   at Unity.IL2CPP.MethodWriter.WriteMethodBody(MethodReference method, CppCodeWriter methodBodyWriter, IRuntimeMetadataAccess metadataAccess)
   at Unity.IL2CPP.MethodWriter.WriteMethodWithMetadataInitialization(CppCodeWriter writer, String methodSignature, String methodFullName, Action`3 writeMethodBody, String uniqueIdentifier)
   at Unity.IL2CPP.MethodWriter.WriteMethodDefinition(MethodReference method, IMethodCollector methodCollector, IMethodVerifier methodVerifier)
   at Unity.IL2CPP.MethodWriter.WriteMethodDefinitions(IMethodCollector methodCollector, IMethodVerifier methodVerifier)
   at Unity.IL2CPP.SourceWriter.WriteMethodSourceFiles(NPath outputDirectory, String fileName, IEnumerable`1 typeList, IMethodCollector methodCollector, IMethodVerifier methodVerifier, IInteropDataCollector interopDataCollector, SymbolsCollector symbolsCollector, Boolean writeMarshalingDefinitions)
   at Unity.IL2CPP.SourceWriter.Write(AssemblyDefinition assemblyDefinition, ReadOnlyInflatedCollectionCollector allGenerics, NPath outputDir, TypeDefinition[] typeList, AttributeCollection attributeCollection, MethodCollector methodCollector, IMethodVerifier methodVerifier, IInteropDataCollector interopDataCollector, IMetadataCollection metadataCollection, SymbolsCollector symbolsCollector)
   at Unity.IL2CPP.AssemblyConverter.Apply()
   at Unity.IL2CPP.AssemblyConverter.ConvertAssemblies(NPath[] assemblies, NPath outputDir, NPath dataFolder, NPath symbolsFolder)
   at Unity.IL2CPP.AssemblyConverter.ConvertAssemblies(IEnumerable`1 assemblyDirectories, IEnumerable`1 explicitAssemblies, NPath outputDir, NPath dataFolder, NPath symbolsFolder)
   at il2cpp.Program.DoRun(String[] args)
   at il2cpp.Program.Run(String[] args)
   at il2cpp.Program.Main(String[] args)
stderr:

Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
   at Unity.IL2CPP.MethodBodyWriter.GetMethodCallExpression(MethodReference callingMethod, MethodReference methodToCall, MethodReference unresolvedMethodtoCall, TypeResolver typeResolverForMethodToCall, MethodCallType callType, IRuntimeMetadataAccess runtimeMetadataAccess, VTableBuilder vTableBuilder, IEnumerable`1 argumentArray, Boolean useArrayBoundsCheck, Func`2 addUniqueSuffix)
   at Unity.IL2CPP.MethodBodyWriter.CallExpressionFor(MethodReference callingMethod, MethodReference unresolvedMethodToCall, MethodCallType callType, List`1 poppedValues, Func`2 addUniqueSuffix, Boolean emitNullCheckForInvocation)
   at Unity.IL2CPP.MethodBodyWriter.ProcessInstruction(Node node, InstructionBlock block, Instruction& ins)
   at Unity.IL2CPP.MethodBodyWriter.GenerateCodeRecursive(Node node)
   at Unity.IL2CPP.MethodBodyWriter.Generate()
   at Unity.IL2CPP.MethodWriter.WriteMethodBody(MethodReference method, CppCodeWriter methodBodyWriter, IRuntimeMetadataAccess metadataAccess)
   at Unity.IL2CPP.MethodWriter.WriteMethodWithMetadataInitialization(CppCodeWriter writer, String methodSignature, String methodFullName, Action`3 writeMethodBody, String uniqueIdentifier)
   at Unity.IL2CPP.MethodWriter.WriteMethodDefinition(MethodReference method, IMethodCollector methodCollector, IMethodVerifier methodVerifier)
   at Unity.IL2CPP.MethodWriter.WriteMethodDefinitions(IMethodCollector methodCollector, IMethodVerifier methodVerifier)
   at Unity.IL2CPP.SourceWriter.WriteMethodSourceFiles(NPath outputDirectory, String fileName, IEnumerable`1 typeList, IMethodCollector methodCollector, IMethodVerifier methodVerifier, IInteropDataCollector interopDataCollector, SymbolsCollector symbolsCollector, Boolean writeMarshalingDefinitions)
   at Unity.IL2CPP.SourceWriter.Write(AssemblyDefinition assemblyDefinition, ReadOnlyInflatedCollectionCollector allGenerics, NPath outputDir, TypeDefinition[] typeList, AttributeCollection attributeCollection, MethodCollector methodCollector, IMethodVerifier methodVerifier, IInteropDataCollector interopDataCollector, IMetadataCollection metadataCollection, SymbolsCollector symbolsCollector)
   at Unity.IL2CPP.AssemblyConverter.Apply()
   at Unity.IL2CPP.AssemblyConverter.ConvertAssemblies(NPath[] assemblies, NPath outputDir, NPath dataFolder, NPath symbolsFolder)
   at Unity.IL2CPP.AssemblyConverter.ConvertAssemblies(IEnumerable`1 assemblyDirectories, IEnumerable`1 explicitAssemblies, NPath outputDir, NPath dataFolder, NPath symbolsFolder)
   at il2cpp.Program.DoRun(String[] args)
   at il2cpp.Program.Run(String[] args)
   at il2cpp.Program.Main(String[] args)

Solution was, delete all dlls, reimport all dlls, kick unity IAP a few times over and then import it from the asset store as importing from the services menu is pretty horrific and then it worked.

1 Like