Search Unity

UNetWeaver Null Exception When Building for Windows 10 Store

Discussion in 'UNet' started by nomo, Feb 21, 2019.

  1. nomo

    nomo

    Joined:
    Apr 4, 2013
    Posts:
    8
    Hey there! So I have recently started porting my UNet multiplayer based mobile game over to the Windows 10 Store. The project is based in Unity 5.6.6f2. After a bit of a false start in attempting to transition all our code and plugins over to .NetCore, I have since realized that I can (and probably should) just be using IL2CPP for our script backend. The API level is set to .Net 4.6 for compatibility with Unity IAP. Things were looking good until encountering the build error relating to UnetWeaver in the provided log output. I have reviewed the ProcessSyncVars() code in UNetWeaver.NetworkBehaviourProcessor available on GitHub in an attempt to understand how the exception might occur. My project only has one class that NetworkBehaviour and it does utilize its serialization functionality though it does so through custom serialization methods and not via the SyncVars attribute. Furthermore, this code all builds and works great on other platforms so clearly there's more to this situation as it relates to Windows Store player builds (and asset bundle builds). Any insight would be greatly appreciated!

    Code (CSharp):
    1. WeaveAssemblies unityPath= C:\Program Files\Unity\Editor\Data\PlaybackEngines\MetroSupport/Tools/UnityEngine.dll
    2. WeaveAssemblies unetPath= C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/Networking/UnityEngine.Networking.dll
    3. Platform assembly: C:\Program Files\Unity\Editor\Data\Managed\Mono.Cecil.Pdb.dll (this message is harmless)
    4. Platform assembly: C:\Program Files\Unity\Editor\Data\Managed\Mono.Cecil.Mdb.dll (this message is harmless)
    5. Symbols will be read from Temp/Assembly-CSharp-firstpass.pdb
    6. Script Module: Assembly-CSharp-firstpass.dll
    7. Pass: 0 took 39 milliseconds
    8. [NetworkCustomMessage] MessageClassProcessor for NetworkCustomMessage
    9. [NetworkCustomMessage] MessageClassProcessor Start
    10. [NetworkCustomMessage]   GenerateSerialization
    11. [NetworkCustomMessage]   GenerateDeserialization
    12. [NetworkCustomMessage] MessageClassProcessor Done
    13. [NetworkRawDataMessage] MessageClassProcessor for NetworkRawDataMessage
    14. [NetworkRawDataMessage] MessageClassProcessor Start
    15. [NetworkRawDataMessage]   GenerateSerialization
    16. [NetworkRawDataMessage]   GenerateDeserialization
    17. [NetworkRawDataMessage] MessageClassProcessor Done
    18. [NetworkBehaviourEvents] Found NetworkBehaviour NetworkBehaviourEvents
    19. [NetworkBehaviourEvents] NetworkBehaviourProcessor
    20. [NetworkBehaviourEvents] Process Start
    21. UNetWeaver error: Exception :System.NullReferenceException: Object reference not set to an instance of an object
    22.   at Unity.UNetWeaver.Weaver.IsDerivedFrom (Mono.Cecil.TypeDefinition td, Mono.Cecil.TypeReference baseClass) [0x00002] in C:\buildslave\unity\build\Extensions\Networking\Weaver\UNetWeaver.cs:1558
    23.   at Unity.UNetWeaver.NetworkBehaviourProcessor.ProcessSyncVars () [0x00358] in C:\buildslave\unity\build\Extensions\Networking\Weaver\UNetBehaviourProcessor.cs:2137
    24.   at Unity.UNetWeaver.NetworkBehaviourProcessor.Process () [0x00059] in C:\buildslave\unity\build\Extensions\Networking\Weaver\UNetBehaviourProcessor.cs:54
    25.   at Unity.UNetWeaver.Weaver.ProcessNetworkBehaviourType (Mono.Cecil.TypeDefinition td) [0x00093] in C:\buildslave\unity\build\Extensions\Networking\Weaver\UNetWeaver.cs:1127
    26.   at Unity.UNetWeaver.Weaver.CheckNetworkBehaviour (Mono.Cecil.TypeDefinition td) [0x000a0] in C:\buildslave\unity\build\Extensions\Networking\Weaver\UNetWeaver.cs:1657
    27.   at Unity.UNetWeaver.Weaver.Weave (System.String assName, IEnumerable`1 dependencies, IAssemblyResolver assemblyResolver, System.String unityEngineDLLPath, System.String unityUNetDLLPath, System.String outputDir) [0x000df] in C:\buildslave\unity\build\Extensions\Networking\Weaver\UNetWeaver.cs:1778
    28. UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
    29. UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    30. UnityEngine.Logger:Log(LogType, Object)
    31. UnityEngine.Debug:LogError(Object)
    32. Unity.UNetWeaver.Log:Error(String) (at C:\buildslave\unity\build\Extensions\Networking\Weaver\Program.cs:20)
    33. Unity.UNetWeaver.Weaver:WeaveAssemblies(IEnumerable`1, IEnumerable`1, IAssemblyResolver, String, String, String) (at C:\buildslave\unity\build\Extensions\Networking\Weaver\UNetWeaver.cs:1886)
    34. 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)
    35. UnityEditor.Scripting.Serialization.Weaver:WeaveInto(String, String, String, String, String[], IAssemblyResolver) (at C:\buildslave\unity\build\Editor\Mono\Scripting\Serialization\Weaver.cs:106)
    36. UnityEditor.Scripting.Serialization.Weaver:WeaveUnetFromEditor(String, String, String, String, Boolean) (at C:\buildslave\unity\build\Editor\Mono\Scripting\Serialization\Weaver.cs:74)
    37. UnityEditor.BuildPipeline:BuildAssetBundlesWithInfoInternal(String, AssetBundleBuild[], BuildAssetBundleOptions, BuildTargetGroup, BuildTarget)
    38. UnityEditor.BuildPipeline:BuildAssetBundles(String, AssetBundleBuild[], BuildAssetBundleOptions, BuildTargetGroup, BuildTarget) (at C:\buildslave\unity\build\artifacts\generated\common\editor\BuildPipelineBindings.gen.cs:531)
    39. UnityEditor.BuildPipeline:BuildAssetBundles(String, AssetBundleBuild[], BuildAssetBundleOptions, BuildTarget) (at C:\buildslave\unity\build\artifacts\generated\common\editor\BuildPipelineBindings.gen.cs:519)
     
  2. nomo

    nomo

    Joined:
    Apr 4, 2013
    Posts:
    8
    Update! I was able to work past this specific build issue. For whatever reason UNetWeaver's post processing of my class that extends NetworkBehaviour does not like encountering events that use System.Action in their signature.

    This code fails with the error mentioned in my previous post.
    Code (CSharp):
    1. // using System.Action results in UNetWeaver build issues.
    2. public event System.Action    NetworkDestroyEvent;
    This code builds just fine with IL2CPP.
    Code (CSharp):
    1. // however defining a delegate just like System.Action
    2. public delegate void OnNetworkEvent();
    3. // ...works fine for my event.
    4. public event OnNetworkEvent NetworkDestroyEvent;
    With this issue behind me (hopefully), I'm now onto build issues with the Visual Studio solution resulting from the player build. The project doesn't even load correctly in VS2017. After hacking the project's Platform Toolset back to v140 I was able to get it to load and mostly compile with VS2015 with the exception of the following compiler error.

    vccorlib.h(348): error C3940: 'EventRegistrationToken': identifier not found - possible mismatch between compiler and library versions. Please ensure vccorlib.h/.lib, vccorlib120.dll and c1xx.dll match

    Guessing maybe there's some discrepancy between the Windows platform version IL2CPP is generating code for vs what VS is building against...or something.