Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Mono Upgrade "Editor can only use assemblies targeting .NET 3.5 or lower"

Discussion in 'Experimental Scripting Previews' started by djTomServo2, Oct 8, 2016.

  1. djTomServo2

    djTomServo2

    Joined:
    Mar 22, 2013
    Posts:
    14
    Hey all!

    Hope I'm not misunderstanding here, I have some managed dlls that are built targeting .NET 4.5 and when I inspect them in the project view, I get this message:

    "Plugin targets .NET 4.x and is marked as compatible with Editor, Editor can only use assemblies targeting .NET 3.5 or lower, please unselect Editor as compatible platform."

    When I uncheck Editor in the platform settings, the message disappears, is this expected behavior for now? I did set my player settings to target .NET 4.6, am I missing a step?
     
  2. joncham

    joncham

    Unity Technologies

    Joined:
    Dec 1, 2011
    Posts:
    276
    We didn't remove that warning by accident (bug). It used to make sense when the Editor was .Net 2.0/3.5, but it doesn't apply to this preview build supporting .Net 4.6.
     
  3. jugdemon

    jugdemon

    Joined:
    Dec 17, 2014
    Posts:
    8
    Hello joncham,
    I m having a similar problem. However, I cannot reference the DLL in C# source code and the only problem I can find is the message that a 4.x library is not compatible. Could it be that the error message (not warning!) stops unity from properly loading the DLL?
    Best wishes,
    jugdemon
     
  4. djTomServo2

    djTomServo2

    Joined:
    Mar 22, 2013
    Posts:
    14
    This is the issue I'm seeing, the message shows up as an error vs a warning, and then I'm unable to reference the DLL functionality in my scripts.
     
  5. mc1695

    mc1695

    Joined:
    Jun 3, 2016
    Posts:
    3
    Hi,

    I'm having this issue too, I have a set of c# class libraries that use .net 4.6 and they can't be referenced in Unity/VS either. I can send you the project files if that would help? I've upgraded VSTU and that doesn't seem to have made a difference either.

    I do however no longer get any error messages when import these into the project, when importing them in 5.3 i would get this error: "System.Reflection.ReflectionTypeLoadException". Interestingly the dll would then get added to the VS project references. In this beta though the DLLs are not added to the references.

    Thanks,

    Sam
     
  6. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,935
    We've been able to reproduce and correct this issue actually, so we don't need the project files in this case - thanks for the offer though! This should be corrected in the next preview build we release. Look for it on this forum soon.
     
  7. djTomServo2

    djTomServo2

    Joined:
    Mar 22, 2013
    Posts:
    14
    Outstanding, Thanks Josh!
     
  8. PortaDiFerro

    PortaDiFerro

    Joined:
    Oct 13, 2016
    Posts:
    2
    I couldn't get 4.5 DLL:s working either, hopefully the fix will come soon. Been exploring Unity as an option for a while now and I really like it, but we can't switch to it until it has .net 4.5+. Waiting excitedly :)
     
  9. joncham

    joncham

    Unity Technologies

    Joined:
    Dec 1, 2011
    Posts:
    276
  10. PortaDiFerro

    PortaDiFerro

    Joined:
    Oct 13, 2016
    Posts:
    2
    Yay, nice work! Now I can see my 4.5 dll in the script. However haven't gotten much further than that since I found some crash bug. The bug report in the help menu doesn't seem to be working though.
     
  11. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,935
    @PortaDiFerro

    Yes, since this is an editor-only installation, the bug reporter is not part of the install package. Can you use the bug reporter from a different version of Unity to submit the bug report?
     
  12. Jeremy-Alessi

    Jeremy-Alessi

    Joined:
    Oct 18, 2007
    Posts:
    125
    What is going on with this? Should the latest release of Unity support mcs dlls in the editor or not? I just compiled dlls with MonoBleedingEdge mcs and they fail to load in the editor.
     
  13. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,935
    @Jeremy-Alessi

    That should work. Do you see an error message in the Editor.log when the assembly fails to load?
     
  14. marija

    marija

    Joined:
    Dec 30, 2014
    Posts:
    2
    We are experiencing the same issue with the latest release of Unity 5.5.0f3. In our Editor.log there's only info that compilation had failure. Do you have an idea what could be the issue?
     
  15. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,935
    @marija

    Can you submit a bug report for this issue? It might be slightly different than the original issue discussed here, as I think that issue only occurred with the experimental build using the new Mono runtime. However, if it does impact the released 5.5 build, we should be able to get a fix into a patch release soon.
     
  16. van800

    van800

    JetBrains Employee

    Joined:
    May 19, 2016
    Posts:
    73
  17. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,935
    @van800

    Thanks for submitting this bug report. After taking a closer look, I don't believe that this is supported. In the release builds for 5.5 and 5.6, Unity only supports .NET 3.5 still. Hence, it should not be possible to import a .NET 4 assembly. In the experimental preview build, .NET 4 is supported, so this works.
     
  18. marija

    marija

    Joined:
    Dec 30, 2014
    Posts:
    2
    @JoshPeterson It was bug on our side. I'm sorry. You can delete related posts as they are off topic.
     
  19. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,935
    @marija

    No problem thanks for letting me know. I'm not sure that I have permission to delete posts; I'm fine with leaving them.
     
  20. shaderbytes

    shaderbytes

    Joined:
    Nov 11, 2010
    Posts:
    900
    I just ran into this issue using unity 5.5.0f3.

    This worked perfectly in unity 5.4 and 5.3.

    I opened and upgraded the project to be greeted by the error messages about cant upgrade everything because of errors

    the errors are related to code referencing aspects of a dll. when inspecting the dll it has the inspector error saying problem with .net target .. same as what others have said above. This is a regressive bug because as mentioned this worked in previous unity versions.
     
  21. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,935
    @shaderbytes

    Can you submit a bug report with this project? If we have caused a regression from 5.4 and 5.3, we will certainly correct it. I'm surprised that a .NET 4 assembly ever worked with 5.4 or 5.3 though - it should not have.
     
  22. shaderbytes

    shaderbytes

    Joined:
    Nov 11, 2010
    Posts:
    900
    The project file size is my concern for submitting a bug, i will see if I can do it over night ( free data after 12pm ) :)

    For interests sake , the dll was created using TlbImp.exe , which is found in the .net install folders. I use it to create a dll that marshals unmanaged to managed code of another 3rd party dll that is registered as a com object. When launching the game , I also launch the 3rd party software and then communicate with it for game play. The 3rd party software is VPinMame, which emulates real world roms of pinball machines.

    Here is a working version of the game compiled with 5.4 :

    https://drive.google.com/open?id=0B5GQag5iS_vzWHZDazNFZVNIOTg

    I will let you know when the bug has been reported with a case number
     
  23. pKallv

    pKallv

    Joined:
    Mar 2, 2014
    Posts:
    1,191
    I have this problem with 5.6 also?
     
  24. M_R

    M_R

    Joined:
    Apr 15, 2015
    Posts:
    559
    I submitted a report for something similar. (Case 889212).

    I was using protobuf.net to generate serialization code for my data.
    a workaround could be installing an old mono (v2.6.x) and running the tool with the old runtime, if the tool works with it
     
  25. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,935
    In Unity 5.6, this is still not supported. In the release builds for 5.5 and 5.6, Unity only supports .NET 3.5 still. Hence, it should not be possible to import a .NET 4 assembly. In the experimental preview build, .NET 4 is supported, so this works.
     
  26. pKallv

    pKallv

    Joined:
    Mar 2, 2014
    Posts:
    1,191
    ...but how do i het SQLite3 to work then?
     
  27. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,935
    Is SQLite3 compiled against the .NET 4.6 profile? If so, then it won't work with Unity 5.6. If there is a version that is compiled against .NET 3.5, it should work. Sorry, I'm not familiar with SQLite 3 enough to provide a specific answer though.
     
  28. pKallv

    pKallv

    Joined:
    Mar 2, 2014
    Posts:
    1,191
    So what database solution do you recommend that work with 5.6?
     
  29. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,935
    Sorry, I'm unfamiliar with database options for use with Unity. Maybe someone else can help though.
     
  30. leutnant_kane

    leutnant_kane

    Joined:
    Apr 29, 2015
    Posts:
    40
    Facing this problem with the 2017 Unity Beta Version. Inspector shows an Error about only being compatible with .Net 3.5 and I can't access the dll from my code. I thought this should work with the Beta?

    EDIT: Alrighty, found the option in the player settings to switch .net versions. This of course causes the project to crash on opening reliably. Anyway to get around that yet?
     
    Last edited: Apr 15, 2017
  31. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,935
    @leutnant_kane

    Can you submit a bug report with the project that causes a crash? That should not happen, and indeed, many projects work fine with the new Mono runtime and .NET 4.6. So we would really like to determine what is causing the crash in this case.
     
  32. leutnant_kane

    leutnant_kane

    Joined:
    Apr 29, 2015
    Posts:
    40
    I've just submitted a bug report, should be easily reproduceable^^

    Edit: Do you need the case number?
     
  33. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,935
    Yes, please provide the case number. Then I can route the bug report correctly.
     
  34. leutnant_kane

    leutnant_kane

    Joined:
    Apr 29, 2015
    Posts:
    40
    alright, it's Case 902670. I'm interested to see what you find out^^
     
  35. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,935
    We have found the source of this problem and corrected it. The issue was related to how Unity was using the Mono embedding API in one case. The fix will be in a 2017.1 beta release (probably 20171.b3, although we might miss that release train).
     
  36. jordirp83

    jordirp83

    Joined:
    Oct 4, 2017
    Posts:
    1
    Hi, I still have this problem with version Unity 2017.2.0, when trying importing a DLL compiled with .NET4.5 I have this same error message and the DLL is not referenced in the project assemblies.

    If I recompile the DLL in .NET3.5 it works but I need to add DLLs that are only .NET4.5

    Using Unity Editor for Windows + Visual Studio 2017

    Thanks!
     
  37. joncham

    joncham

    Unity Technologies

    Joined:
    Dec 1, 2011
    Posts:
    276
    Can you please file a bug with additional information to reproduce this? Thanks.
     
  38. neoulshim

    neoulshim

    Joined:
    Nov 11, 2017
    Posts:
    4
    I have the same problem. I'll send you a stripped version of my project.
     
    JoshPeterson likes this.
  39. jrkirby_unity

    jrkirby_unity

    Joined:
    Feb 15, 2016
    Posts:
    2
  40. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,935
    Can you submit a bug report for this issue?
     
  41. jrkirby_unity

    jrkirby_unity

    Joined:
    Feb 15, 2016
    Posts:
    2
    I found a solution:

    file -> build settings -> player settings -> Script Runtime Version

    Change from Stable to Experimental

    I had missed that I needed to change the default settings.
     
  42. gStormDesign

    gStormDesign

    Joined:
    May 27, 2013
    Posts:
    30
    Hey, yes, and apparently this is a very long standing problem. Several unity versions, bug reports and fixes, same issue. The runtime .NET 4.x option is not helpful in my case for tools configured and used in the editor (and runtime). This was super easy in the Unity distribution of MonoDevelop, that make it frustrating to run into this wall with the Unity distribution of Visual Studio 2017