SaladLab / Unity3D.IncrementalCompiler

Unity3D Incremental C# Compiler using Roslyn
MIT License
354 stars 37 forks source link

Compilation error with Unity 5.3.5p8 #12

Open Godefroy opened 8 years ago

Godefroy commented 8 years ago

Hi !

This compiler seems really promising but I've got an error with Unity 5.3.5p8 which prevents me from using it:

Client log :

2016-07-19 19:33:53.8412 INFO|Client|Request to server|
2016-07-19 19:33:59.2131 ERROR|Client|Error in request|System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail] : La référence d'objet n'est pas définie à une instance d'un objet. (le détail de l'erreur est égal à ExceptionDetail, probablement créé par IncludeExceptionDetailInFaults=True, dont la valeur est :
System.NullReferenceException: La référence d'objet n'est pas définie à une instance d'un objet.
   à IncrementalCompiler.Compiler.GetDiagnosticString(Diagnostic diagnostic, String type)
   à IncrementalCompiler.Compiler.Emit(CompileResult result)
   à IncrementalCompiler.Compiler.BuildFull(CompileOptions options)
   à IncrementalCompiler.Compiler.Build(CompileOptions options)
   à IncrementalCompiler.CompilerService.Build(String projectPath, CompileOptions options)
   à SyncInvokeBuild(Object , Object[] , Object[] )
   à System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
   à System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
   à System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
   à System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc)...).
2016-07-19 19:34:01.0597 INFO|Client|Done: Succeeded=True. Duration=7,215534sec.|

Server log :

2016-07-19 19:33:59.1690 ERROR|CompilerService|Error in build.|System.NullReferenceException: La référence d'objet n'est pas définie à une instance d'un objet.
   à IncrementalCompiler.Compiler.GetDiagnosticString(Diagnostic diagnostic, String type)
   à IncrementalCompiler.Compiler.Emit(CompileResult result)
   à IncrementalCompiler.Compiler.BuildFull(CompileOptions options)
   à IncrementalCompiler.Compiler.Build(CompileOptions options)
   à IncrementalCompiler.CompilerService.Build(String projectPath, CompileOptions options)

Do you have an idea of how to fix this?

Godefroy commented 8 years ago

Hmm it seems to work with another project. I don't know how to find what's causing the issue on my first project.

veblush commented 8 years ago

When the compiler encounters an error while compile, it generates error messages. But this exception seems to be thrown by GetDiagnosticString which does not handle null of fields of Diagnostic carrying error information. I'll make a fix for it. Thanks!

veblush commented 8 years ago

This fix is just done. Please check it out. latest release. If this works, let me know what kind of message start with 'None`.

Godefroy commented 8 years ago

Wow you're fast, thanks a lot! I'm testing that.

Godefroy commented 8 years ago

I think we now have a hint:

IncrementalCompiler.log:

2016-07-20 10:03:32.3074 INFO|Client|None: warning CS1685: The predefined type 'ExtensionAttribute' is defined in multiple assemblies in the global alias; using definition from 'System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'|

Compilation finishes, no error in any log except this warning, but the dll is invalid.

In Unity3D:

UNetWeaver error: Exception :System.BadImageFormatException: Format of the executable (.exe) or library (.dll) is invalid.
  at Mono.Cecil.PE.ImageReader.ReadImage () [0x00000] in <filename unknown>:0 
  at Mono.Cecil.PE.ImageReader.ReadImageFrom (System.IO.Stream stream) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ModuleDefinition.ReadModule (System.IO.Stream stream, Mono.Cecil.ReaderParameters parameters) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.ModuleDefinition.ReadModule (System.String fileName, Mono.Cecil.ReaderParameters parameters) [0x00000] in <filename unknown>:0 
  at Mono.Cecil.AssemblyDefinition.ReadAssembly (System.String fileName, Mono.Cecil.ReaderParameters parameters) [0x00000] in <filename unknown>:0 
  at Unity.UNetWeaver.Weaver.Weave (System.String assName, IEnumerable`1 dependencies, IAssemblyResolver assemblyResolver, System.String unityEngineDLLPath, System.String unityUNetDLLPath, System.String outputDir) [0x00032] in C:\buildslave\unity\build\Extensions\Networking\Weaver\UNetWeaver.cs:1640 
  at Unity.UNetWeaver.Weaver.WeaveAssemblies (IEnumerable`1 assemblies, IEnumerable`1 dependencies, IAssemblyResolver assemblyResolver, System.String outputDir, System.String unityEngineDLLPath, System.String unityUNetDLLPath) [0x00062] in C:\buildslave\unity\build\Extensions\Networking\Weaver\UNetWeaver.cs:1753 
UnityEngine.Debug:LogError(Object)
Unity.UNetWeaver.Log:Error(String) (at C:/buildslave/unity/build/Extensions/Networking/Weaver/Program.cs:20)
Unity.UNetWeaver.Weaver:WeaveAssemblies(IEnumerable`1, IEnumerable`1, IAssemblyResolver, String, String, String) (at C:/buildslave/unity/build/Extensions/Networking/Weaver/UNetWeaver.cs:1760)
Unity.UNetWeaver.Program:Process(String, String, String, String[], String[], IAssemblyResolver, Action`1, Action`1) (at C:/buildslave/unity/build/Extensions/Networking/Weaver/Program.cs:34)
UnityEditor.Scripting.Serialization.Weaver:WeaveUnetFromEditor(String, String, String, String, Boolean)
veblush commented 8 years ago

Wow it's a bizarre warning that I've never seen. At first, is there a suspicious DLL in your project? From stackoverflow, it's possible to have DLLs targeting different framework in your case.

Which DLL does Unity3D cannot load? Is it an Assembly-CSharp.dll in ./Library/ScriptAssemblies or something else. And is it an zero-size DLL?

Godefroy commented 8 years ago

Ok now it's working when I remove two extensions:

Error with Online Maps:

The type 'XmlElement' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Xml, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.
veblush commented 8 years ago

It's good to be working now. :smile: But I cannot try to find what's wrong with them because they're not free.

For error about XmlElement, Incremental Compiler always refers to System.Xml, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e so it's strange to have this error. Any idea about Online Map package?

00christian00 commented 8 years ago

Slate do work fine. I can't test Online Maps, but I remember a similar error on normal Unity too. Do you perhaps have .NET 2.0 subset selected in the player setting? It may be the issue.