Search Unity

How to debug Serialization Weaver Exception?

Discussion in 'Windows' started by fjhamming_CleVR, Nov 26, 2014.

  1. fjhamming_CleVR

    fjhamming_CleVR

    Joined:
    Feb 6, 2014
    Posts:
    10
    When building for windows phone or windows store I Get the following Exception:
    I was wondering if there is a way to determine which part causes the exception and/or how to ignore it and continue. The project builds and works fine on android and windows standalone.
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

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

    which Unity version is this? It looks to be a bug in SerializationWeaver, and it happens when processing some generic parameter in CleVR.Engine.Characters.Model.CharacterModelData class.
     
  3. fjhamming_CleVR

    fjhamming_CleVR

    Joined:
    Feb 6, 2014
    Posts:
    10
    Hi,

    Thanks for the fast reply. We are currently using Unity 4.5.5f1

    There are no generics in that class. The class is however full of binary enums and there are some extension methods defined elsewhere of which one is generic.

    Any clues for the next step?
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    You're right - it writes out the class name after it's done with it, not before. However, I believe you should still be able to find the troublemaker with a little bit of effort.

    Fortunately for you, SerializationWeaver processes the classes in a well defined order - in the same order they are defined in your assembly. It processes all types that meet following criteria:

    * Are not enums;
    * Are not generic;
    * Derive from MonoBehaviour, ScriptableObject OR has System.Serializable attribute applied to the type.

    Now, the last part is to find the order of the types defined in the assembly. For that, you'll need an IL disassembler. I personally recommend Mono.Cecil (https://www.nuget.org/packages/Mono.Cecil/). It's a library that lets you manipulate managed assemblies from C#. You can also find it somewhere in Unity's installation folder if you don't wish to download it.

    If you choose to use that, here's the sample code that will print out all the types in specified assembly:

    Code (csharp):
    1.  
    2. private static void PrintType(TypeDefinition type)
    3. {
    4.     foreach (var nestedType in type.NestedTypes)
    5.     {
    6.         PrintType(nestedType);
    7.     }
    8.  
    9.     Console.WriteLine(type.FullName);
    10. }
    11.  
    12. private static int Main(string[] args)
    13. {
    14.     const string inputFile = @"<PATH_TO_CleVR.Engine.Characters.dll";
    15.  
    16.     var assembly = ReadAssembly(inputFile);
    17.     var module = assembly.MainModule;
    18.    
    19.     foreach (var type in module.Types)
    20.     {
    21.         PrintType(type);
    22.     }
    23. }
    24.  
    Also, it would be nice if we could get a bug report for this.
     
  5. fjhamming_CleVR

    fjhamming_CleVR

    Joined:
    Feb 6, 2014
    Posts:
    10
    The next class in the list is quite similar to the CharacterModelData class, but it's a profile that allows to set multiple values for each of the binary enums where charactermodeldata allows only one value for each enum.

    Anyway, I'll file a bug report. Hope it helps
     
  6. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,822
    Also try building your Unity project to a brand new folder.
    Sometimes there is a reference in the build steps in the VS solution that causes this error.