Search Unity

Player Postprocess Exception - Failed to run Serialization weaver

Discussion in 'Windows' started by Dom3D, Dec 1, 2013.

  1. Dom3D

    Dom3D

    Joined:
    Dec 19, 2012
    Posts:
    21
    Any idea what could cause the following build-step exception?

    Code (csharp):
    1. Error building Player: Exception: Failed to run Serialization weaver with cmdline "Temp/StagingArea\Data/Managed/Plugins/Metro\WindowsStorePlatformCode.dll" -pdb -verbose -unity-engine=Temp/StagingArea\Managed/UnityEngine.dll "Temp/StagingArea\TempSerializationWeaver".[Temp/StagingArea\Data/Managed/Plugins/Metro\WindowsStorePlatformCode.dll]
    2. Symbols will be read from Temp/StagingArea\Managed/UnityEngine.pdb
    3. Weaving assembly C:\Users\XXXX\Desktop\XXXX\XXXX\Temp\StagingArea\Data\Managed\Plugins\Metro\WindowsStorePlatformCode.dll
    4. Symbols will be read from Temp/StagingArea\Data/Managed/Plugins/Metro\WindowsStorePlatformCode.pdb
    5. System.NotSupportedException: Specified method is not supported.
    6.    at Mono.Cecil.PE.ImageReader.ReadArchitecture()
    7.    at Mono.Cecil.PE.ImageReader.ReadImage()
    8.    at Mono.Cecil.PE.ImageReader.ReadImageFrom(Stream stream)
    9.    at Mono.Cecil.ModuleDefinition.ReadModule(Stream stream, ReaderParameters parameters)
    10.    at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters)
    11.    at usw.Weaver.WeaveAssembly(String assemblyPath, AssemblyDefinition unityEngineAssemblyDefinition)
    12.    at usw.Weaver.Weave()
    13.    at usw.Program.RunProgram(ConversionOptions options)
    14.    at usw.Program.Main(String[] args)
    15.  
    I did a xamarin scan of my Metro\WindowsStorePlatformCode.dll and got 100%.
     
  2. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,918
    It's probably compiled against ARM architecture, could you switch it to AnyCPU?
     
  3. pjain168

    pjain168

    Joined:
    Jul 1, 2013
    Posts:
    3
    We seem to be getting the same error when we try to build for Windows Store (XAML C#, SDK 8.1 ) using prime31's Metro Essentials plugin and including their demo scene. Here is the error log:

    Code (csharp):
    1.  
    2. Error building Player: Exception: Failed to run Serialization weaver with cmdline "Temp/StagingArea\Data/Managed\Assembly-CSharp-firstpass.dll" -pdb -verbose -unity-engine=Temp/StagingArea\Managed/UnityEngine.dll "Temp/StagingArea\TempSerializationWeaver".[Temp/StagingArea\Data/Managed\Assembly-CSharp-firstpass.dll]
    3. Symbols will be read from Temp/StagingArea\Managed/UnityEngine.pdb
    4. Weaving assembly E:\Unity\XXXXXX\XXXXXX\TestMetro\Windows8Prime31MetroEssnl\Temp\StagingArea\Data\Managed\Assembly-CSharp-firstpass.dll
    5. Symbols will be read from Temp/StagingArea\Data/Managed\Assembly-CSharp-firstpass.pdb
    6. Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Windows, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null'
    7.    at Mono.Cecil.BaseAssemblyResolver.Resolve(AssemblyNameReference name, ReaderParameters parameters)
    8.    at Mono.Cecil.DefaultAssemblyResolver.Resolve(AssemblyNameReference name)
    9.    at Mono.Cecil.MetadataResolver.Resolve(TypeReference type)
    10.    at Unity.CecilTools.Extensions.ResolutionExtensions.Resolve[TReference,TDefinition](TReference reference, Func`2 resolve)
    11.    at Unity.Serialization.Weaver.MethodEmitterBase.WillUnitySerialize(FieldDefinition fieldDefinition)
    12.    at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
    13.    at Unity.Serialization.Weaver.MethodEmitterBase.EmitMethodBody()
    14.    at Unity.Serialization.Weaver.SerializationWeaver.AddSerializeMethod()
    15.    at Unity.Serialization.Weaver.SerializationWeaver.Weave()
    16.    at usw.Weaver.WeaveAssembly(String assemblyPath, AssemblyDefinition unityEngineAssemblyDefinition)
    17.    at usw.Weaver.Weave()
    18.    at usw.Program.RunProgram(ConversionOptions options)
    19.    at usw.Program.Main(String[] args)
    20.  
    21.  
    We had posted this to prime31 support. This is their reply for the above:

    We have a submission closing in and would like to know what the issue is (whether it is Unity / prime31) and how it can be resolved or any workarounds for this.
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Hi,

    I've seen this before and I *believe* it was fixed already in our internal codebase. Either way, don't hesitate to report it.

    What caused it here was non private fields in scripts and types of which were Windows Store specific. For example:

    Code (csharp):
    1.  
    2. class MySuperScript : MonoBehaviour
    3. {
    4. #if NETFX_CORE
    5.     StorageFile m_File;
    6. #endif
    7.  
    8.     void Start()
    9.     {
    10. #if NETFX_CORE
    11.         SetupFile();
    12. #endif
    13.     }
    14.  
    15. #if NETFX_CORE
    16.     async void SetupFile()
    17.     {
    18.         m_File = await openPicker.PickSingleFileAsync();
    19.     }
    20. #endif
    21. }
    22.  
    Such code would cause a very similar error message. To workaround, use a class that is available in .NET 3.5 for field storage, for example System.Object:

    Code (csharp):
    1.  
    2. class MySuperScript : MonoBehaviour
    3. {
    4.     object m_File;
    5.  
    6.     void Start()
    7.     {
    8. #if NETFX_CORE
    9.         SetupFile();
    10. #endif
    11.     }
    12.  
    13. #if NETFX_CORE
    14.     async void SetupFile()
    15.     {
    16.         m_File = await openPicker.PickSingleFileAsync();
    17.     }
    18. #endif
    19. }
    20.  
     
  5. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @Tautvydas, to add a bit more information, I can't seem to reproduce what @pjain168 is seeing on two different Windows PCs. @pjain168 is also the only one who has reported the issue. It seems that the SerializationWeaver failure happens in the Assembly-CSharp-firstpass.dll. Our plugins are all contained in their own DLLs. Is it only code that is compiled into Unity DLLs (such as Assembly-CSharp-firstpass.dll) that cause the issue?

    @pjain168, you should probably use the Unity Bug Reporter to get a copy of your project over to the crew so they can give it a look.
     
  6. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    The code that causes it to crash for pjain is definitely in one of his scripts, not any plugin DLLs (as noted in the SerializationWeaver output).
     
  7. pjain168

    pjain168

    Joined:
    Jul 1, 2013
    Posts:
    3
    I resolved the issue by removing the MetroEssentialsDemoUI.cs script file from the Plugin/Metro folder.
     
  8. GarthSmith

    GarthSmith

    Joined:
    Apr 26, 2012
    Posts:
    1,240
    Last edited: Aug 21, 2014
  9. Leshem

    Leshem

    Joined:
    Mar 23, 2014
    Posts:
    1
    I deleted the TouchScript.mdb and it solved it!
     
    AbgaryanFX likes this.
  10. KevinCodes4Food

    KevinCodes4Food

    Joined:
    Dec 6, 2013
    Posts:
    61
    I managed to fix a similar build stop error which I encountered on 4.5.3f3 building for Windows 8 Store. Complete error follows at the end of my post.

    First, I tried building for WP8, and encountered an error due to a use of StreamReader with a string constructor, which is not supported for the platform. That gave me an idea...

    I switched back to Windows Store player. My Player Settings -> Publishing Settings -> Compilation Settings were either "None" or "Use Net Core Partially". I changed this due to issues I had with a plug-in earlier in testing. Setting this field to "Use Net Core" and building again revealed a bunch of errors with code using incompatible interfaces with Windows Store .NET Framework. These included the StreamRead issue above found in the WP8 build, and using 2 other interfaces incompatible with Windows Store: XmlDocument.SelectNodes() and System.Array.AsReadOnly().

    So I updated to code to not use those incompatible interfaces - and the error is gone! With the removal from our code of the 3 unsupported Windows Phone and Windows 8 interfaces, the problem was completely eliminated. So I would recommend building with "Use Net Core" and double checking that you are only using compatible interfaces with the Windows Store/Windows Phone frameworks.

    It would be nice if these errors could be displayed during editor Unity runs when the platform is selected, rather than just at player build time, but at least this cleared the error.

    Code (CSharp):
    1. Error building Player: Exception: Failed to run Serialization weaver with cmdline "Temp/StagingArea\Data/Managed\Assembly-CSharp.dll" -pdb -verbose -unity-engine="Temp/StagingArea\Managed/UnityEngine.dll" "Temp/StagingArea\TempSerializationWeaver".[Temp/StagingArea\Data/Managed\Assembly-CSharp.dll]
    2. Symbols will be read from Temp/StagingArea\Managed/UnityEngine.pdb
    3. Weaving assembly C:\Development\Unity\Projects\Match3 Candy\Match3Candy\Temp\StagingArea\Data\Managed\Assembly-CSharp.dll
    4.  
    5. Symbols will be read from Temp/StagingArea\Data/Managed\Assembly-CSharp.dll.mdb
    6. + CeilingHelper
    7. + CloudManager
    8. + FadeOutHelper
    9. + GUISizeHelper
    10. + GameManager/Zone
    11. ...
    12. + CameraController
    13. + UniRateEventHandler
    14. + UniRateGUIScript
    15. + UniRate
    16.  
    17. Will export symbols of pdb format
    18.  
    19. System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
    20. at Mono.Cecil.Mdb.MdbReader.ReadLocalVariables(MethodEntry entry, MethodSymbols symbols)
    21. at Mono.Cecil.Mdb.MdbReader.Read(MethodSymbols symbols)
    22. at Mono.Cecil.Cil.CodeReader.PatchRawMethodBody(MethodDefinition method, CodeWriter writer, MethodSymbols& symbols)
    23. at Mono.Cecil.Cil.CodeWriter.WriteUnresolvedMethodBody(MethodDefinition method)
    24. at Mono.Cecil.Cil.CodeWriter.WriteMethodBody(MethodDefinition method)
    25. at Mono.Cecil.MetadataBuilder.AddMethod(MethodDefinition method)
    26. at Mono.Cecil.MetadataBuilder.AddMethods(TypeDefinition type)
    27. at Mono.Cecil.MetadataBuilder.AddType(TypeDefinition type)
    28. at Mono.Cecil.MetadataBuilder.AddNestedTypes(TypeDefinition type)
    29. at Mono.Cecil.MetadataBuilder.AddType(TypeDefinition type)
    30. at Mono.Cecil.MetadataBuilder.AddTypeDefs()
    31. at Mono.Cecil.MetadataBuilder.BuildTypes()
    32. at Mono.Cecil.MetadataBuilder.BuildModule()
    33. at Mono.Cecil.ModuleWriter.<BuildMetadata>b__0(MetadataBuilder builder, MetadataReader _)
    34. at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TItem item, Func`3 read)
    35. at Mono.Cecil.ModuleWriter.WriteModuleTo(ModuleDefinition module, Stream stream, WriterParameters parameters)
    36. at Mono.Cecil.ModuleDefinition.Write(String fileName, WriterParameters parameters)
    37. at usw.Weaver.Weave()
    38. at usw.Program.RunProgram(ConversionOptions options)
    39. at usw.Program.Main(String[] args)
    40.  
     
  11. AbgaryanFX

    AbgaryanFX

    Joined:
    Jan 9, 2010
    Posts:
    167
    worked for, too !