Search Unity

Unity 5.6 assembly importer changes managed manifest mscorlib 2.0.0.0 reference to 4.0.0.0

Discussion in 'Asset Importing & Exporting' started by Paul_Bronowski, May 13, 2017.

  1. Paul_Bronowski

    Paul_Bronowski

    Joined:
    Sep 3, 2014
    Posts:
    55
    We're using Easy Decal and it looks like the Unity API patcher is reaching into their ch.sycoforge.Decal.dll assembly to change an API call (per ildasm diffs)...

    .custom instance void [UnityEngine]UnityEngine.ExecuteInEditMode::.ctor() = ( 01 00 00 00 ) ...
    However it is also adding a reference in the managed assembly manifest...

    PROCESSED BY 5.6
    .assembly extern mscorlib as mscorlib_4
    {
    .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
    .ver 4:0:0:0
    }

    And Visual Studio does not like that. Unity doesn't seem to have a problem with it...

    Warning The primary reference "ch.sycoforge.Decal" could not be resolved because it has an indirect dependency on the .NET Framework assembly "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which has a higher version "4.0.0.0" than the version "2.0.0.0" in the current target framework. MarkOfWar.Plugins

    I can hack the manifest, but a fix would be goodness.

    - thanks
     
    Last edited: May 13, 2017
  2. Sycoforge

    Sycoforge

    Joined:
    Oct 6, 2013
    Posts:
    751
    We are in the process of reproducing this with a test assembly. It really seems like a Unity bug introduced by version 5.6.
     
  3. Paul_Bronowski

    Paul_Bronowski

    Joined:
    Sep 3, 2014
    Posts:
    55
    Agreed - I believe it to be a bug introduced with Unity 5.6. My guess would be that they are accidentally calling the 4.0 ilasm, or it is getting mscorlib from the system env instead of from an explicit 2.0 location...

    Here's my workaround...


    @echo off
    setlocal
    set EasyDecalRoot=[Your path to Assets\Easy Decal]
    set Path=D:\Program Files\Unity\Editor\Data\Mono\lib\mono\2.0;%path%
    set Path=C:\Windows\Microsoft.NET\Framework\v2.0.50727;%path%
    set ilasm=D:\Program Files\Unity\Editor\Data\Mono\lib\mono\2.0\ilasm.exe
    set ildasm=C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\ildasm.exe
    :Step1
    call "ildasm" /NOBAR /ALL ch.sycoforge.Decal_ORIGINAL.dll /out=ch.sycoforge.Decal_ORIGINAL.il
    copy /y "%EasyDecalRoot%\Easy Decal\Scripts\ch.sycoforge.Decal.dll" ch.sycoforge.Decal_BAD.dll
    call "ildasm" /NOBAR /ALL ch.sycoforge.Decal_BAD.dll /out=ch.sycoforge.Decal_BAD.il
    copy /y ch.sycoforge.Decal_BAD.il ch.sycoforge.Decal.il
    echo ACTION REQUIRED: Remove reference to mscorlib_4 and close notepad to continue...
    start /wait notepad.exe ch.sycoforge.Decal.il
    :Step2
    call "ilasm" /NOLOGO /QUIET /DLL /NOAUTOINHERIT ch.sycoforge.Decal.il
    call "ildasm" /NOBAR /ALL ch.sycoforge.Decal.dll /out=ch.sycoforge.Decal_FIXED.il
    start windiff ch.sycoforge.Decal_ORIGINAL.il ch.sycoforge.Decal_FIXED.il
    :Step3
    copy /y ch.sycoforge.Decal.dll "%EasyDecalRoot%\Easy Decal\Scripts\ch.sycoforge.Decal.dll"
     
    Sycoforge likes this.
  4. Paul_Bronowski

    Paul_Bronowski

    Joined:
    Sep 3, 2014
    Posts:
    55
    And it just did it to Tazman Audio's Fabric assembly, after I moved to their patch version. So, not just Easy Decal.
     
    Sycoforge likes this.
  5. Sycoforge

    Sycoforge

    Joined:
    Oct 6, 2013
    Posts:
    751
    Thanks for sharing your workaround! Much appreciated. We submitted a bug report and are waiting for an official statement.
     
  6. Paul_Bronowski

    Paul_Bronowski

    Joined:
    Sep 3, 2014
    Posts:
    55
    Still seeing the problem with a fresh install of todays Unity 5.6.1p2. Booth assemblies munged improperly.
     
  7. Sycoforge

    Sycoforge

    Joined:
    Oct 6, 2013
    Posts:
    751
    We submitted a bug report (case #916719), but haven't heard back until now.
     
  8. Paul_Bronowski

    Paul_Bronowski

    Joined:
    Sep 3, 2014
    Posts:
    55
    Hmm. Not seeing that case number. Perhaps it is flagged as private or not vetted. Do you have a link? - thanks
     
  9. Sycoforge

    Sycoforge

    Joined:
    Oct 6, 2013
    Posts:
    751
    It's flagged as private because we have included the core of the Easy Decal framework (we couldn't figure out what part exactly triggers the injection). I'll send you the link in PM.
     
  10. Sycoforge

    Sycoforge

    Joined:
    Oct 6, 2013
    Posts:
    751
    Case has been confirmed and classified as an bug. Waiting for the answer of the responsible dev team.
     
  11. Mikael-H

    Mikael-H

    Joined:
    Apr 26, 2013
    Posts:
    309
    Is this fixed in Unity 2017 perhaps? Maybe time for me to bite the bullet :)
     
  12. Paul_Bronowski

    Paul_Bronowski

    Joined:
    Sep 3, 2014
    Posts:
    55
    With Unity 2017.1.0p2, it looks like it's now a compiler warning in Visual Studio, not an error...

    Severity Code Description Project File Line Suppression State
    Warning The primary reference "ch.sycoforge.Decal" could not be resolved because it has an indirect dependency on the .NET Framework assembly "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which has a higher version "4.0.0.0" than the version "2.0.0.0" in the current target framework. MarkOfWar.Plugins
     
    Mikael-H likes this.
  13. Paul_Bronowski

    Paul_Bronowski

    Joined:
    Sep 3, 2014
    Posts:
    55
    Still a problem for Unity 2017.1.0p5
     
  14. Mikael-H

    Mikael-H

    Joined:
    Apr 26, 2013
    Posts:
    309
    And 2017.2 beta patch 10

    I am only having this issue when debugging, but I CAN debug by choosing "use latest build". It apparently uses the dll unity built for you when it compiled so works fine. All builds work fine for me, even UWP.
     
    Sycoforge likes this.
  15. Sycoforge

    Sycoforge

    Joined:
    Oct 6, 2013
    Posts:
    751
    Seems to throw now a warning too in Unity 5.6.3...
     
  16. BitAssembler

    BitAssembler

    Joined:
    Jul 13, 2017
    Posts:
    90
    Received an official answer today: This issue should be fixed in Unity 2017.2 with a back port to 2017.1 and maybe also 5.6.x.
     
    Last edited: Sep 30, 2017
    Mikael-H likes this.
  17. Sycoforge

    Sycoforge

    Joined:
    Oct 6, 2013
    Posts:
    751
    Finally! This issue seems to be fixed in 2017.2 and 5.6.4. P1. :)
     
  18. MythArt

    MythArt

    Joined:
    Oct 6, 2013
    Posts:
    7
    The plug-in's DLL in your project has been corrupted by the API Updater. So it's just a matter of replacing it with the original DLL from the plug-in package. That may fix the problem for the time being.

    Extract the plug-in's package in a separate project, and then copy the original un-updated DLL over into your project, replacing your corrupted DLL.