Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

unity 4.1.1: problem compiling dlls using UnityEngine.dll

Discussion in 'Editor & General Support' started by kefrens, Mar 22, 2013.

  1. kefrens

    kefrens

    Joined:
    Feb 24, 2012
    Posts:
    11
    I encountered strange problems after upgrade to 4.1.1. My project is compiled in VisualStudio 12 then I copy dlls to project in Unity. Unfortunately after upgrade from 4.0.1 to 4.1.1 it stopped working. VS C# compiler emits nonsensical errors: such as 'UnityEngine.Rect' doesn't have 'width', "UnityEngine.color' has no 'r' etc.
    I rolled back to 4.0.1 and everything went to normal.
     
  2. UnLogick

    UnLogick

    Joined:
    Jun 11, 2011
    Posts:
    1,745
    Sounds to me like your visual studio project got confused about which binary unityengine.dll it is using.

    Did you install Unity 4.1.1 in the same folder as your 4.0.1 installation? Or did you uninstall the old version? Easiest way to locate a valid unityengine.dll is simply to open a source file from within the UnityEditor and look at the "project" that unity created for you. So make sure to grab the new dll from 4.1.1 and use that to have access to the latest API.

    Open your visual studio and look at the reference to the unityengine.dll in the solution explorer, the problem should be right there.
     
  3. GVGiu

    GVGiu

    Joined:
    May 18, 2010
    Posts:
    6
    I got the same problem, and the way I fixed it for now is going back to 4.1
    I used the auto-generated projects so I believe that issue is with the new UnityEngine.dll and not with any bad configuration from paths or finding the dlls, hope a patch to fix this comes as soon as possible.
     
  4. GVGiu

    GVGiu

    Joined:
    May 18, 2010
    Posts:
    6
    It might be the auto-generated projects are not generated correctly?
     
  5. UnLogick

    UnLogick

    Joined:
    Jun 11, 2011
    Posts:
    1,745
    Well the way I understood OP was that compiling his DLL didn't work. I tested that and it worked.

    What you describe is that you can't use the compiled DLL in your Unity project. And it seems you're right something changed. If you mix DLLs compiled with older versions of Unity in 4.1.1 visual studio wont compile and Unity may actually crash.

    We're looking into the problems behind this. If you have some simple reproducible scenario, like using a particular package from the asset store or something please submit a bug report and write bug number in this thread.
     
  6. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Having the same issue in 4.1.1. If you use/work with DLLs that reference older versions of UnityEngine.dll, neither VS nor MD compile anymore (though Unity compiles and plays without problems). The solution is to re-compile all those DLLs telling them to reference the latest UnityEngine.dll that comes with Unity 4.1.1. But that completely breaks compatibility for assets that should work both with Unity 3.X and Unity 4.

    HOTween's package for example has this issue (as any other DLL, from the feedback I gathered around), since it references UnityEngine.dll that comes with Unity 3, and I solved it by recompiling it with the latest one.

    EDIT: GVGiu, kefrens, let us know if you submitted the bug, otherwise I'll do it
     
    Last edited: Mar 22, 2013
  7. jbevain

    jbevain

    Microsoft

    Joined:
    Feb 22, 2012
    Posts:
    141
    This is a pretty serious ABI breaking change. The good news is that it should be a one time pain only.

    Basically, between 4.0.1 and 4.1.1, UnityEngine.dll and UnityEditor.dll were signed (strongly named).

    This means that for everyone that use a 3rd party assembly that reference either of those, and that is compiled against an earlier version of Unity, if Unity will still compile their project (because they C# compiler that is used internally is a bit more lenient), both MonoDevelop and Visual Studio will fail to compile the project.

    The solution is to recompile the dll against the 4.1.1 Unity assemblies.

    As a workaround, you can import the UnityMigration.unityPackage

    And click on Unity Migration / Unity Reference fixup.

    $Screen Shot 2013-03-22 at 10.07.51 PM.png

    Beware, this is a destructive action : it will patch the DLL in your Assets folder that reference an older version of Unity. But then everything should work.
     
    Last edited: Mar 22, 2013
  8. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Thanks a lot for the package jbevain.

    I hope that this is considered a bug though, and that the UnityEngine/Editor DLLs will be updated to a not strongly signed version as before, to allow easier workflow and usage of 3.x/4 compatible libraries.
     
  9. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    It's good for me that this issue is already known. I am getting bug reports because of it.
     
  10. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Just reported a bug:
    Dll's compiled based on UnityEngine/Editor.dll before Unity 4.1.1 produce errors in MonoDevelop/Xamarin Studio/Visual Studio.

    Case 534056
     
  11. UnLogick

    UnLogick

    Joined:
    Jun 11, 2011
    Posts:
    1,745
    @Izitmee: When a minor version breaks multiple packages from the asset store that's always a bug!

    We got all the info we need on this one, now we just have to find the right solution for everyone moving forward. That may be changing the references of existing DLLs to a signed ones like jbevain's package does or it may be something else so please keep backups of your original DLLs until we know for sure.
     
  12. Zozo2099

    Zozo2099

    Joined:
    Jul 15, 2012
    Posts:
    478
    Just a question, if I downgrade back to 4.1.0 will this problem be gone? you were talking between 4.0.1 and 4.1.1, but there is version 4.1.0 between these two!

    Thanks:
     
  13. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Great, thanks UnLogick for the reassurance :)

    @Zozo2099: 4.1.0 is safe. I rolled back to it and have no such problems.
     
  14. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
  15. HaoEver1987

    HaoEver1987

    Joined:
    Sep 29, 2012
    Posts:
    8
  16. HaoEver1987

    HaoEver1987

    Joined:
    Sep 29, 2012
    Posts:
    8