Search Unity

Unable to locate .NET Framework 4.5

Discussion in 'Editor & General Support' started by macjuul, Sep 12, 2018.

  1. macjuul

    macjuul

    Joined:
    Jun 4, 2018
    Posts:
    2
    Hi! I'm having trouble loading my project into Visual Studio Code and Rider. Both applications tell me I'm missing the .NET Framework 4.5 (Developer Pack) installation.



    I've tried searching for version 4.5, however I'm only able to find 4.5.2, which does not seem to satisfy the editors.

    My question is whether there is a way to install version 4.5, or change the version Unity requires.
    Thanks!
     
    SuperYoshi67 likes this.
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Did you click on the Download link in your screenshot? 4.5.2 should work also, can you elaborate "does not seem to satisfy the editors". I will assume you mean editor, singular. Did you reboot after the install as a test?
     
  3. macjuul

    macjuul

    Joined:
    Jun 4, 2018
    Posts:
    2
    Hey thanks for your reply, the link takes me to https://www.microsoft.com/net/download/visual-studio-sdks, on which I downloaded the 4.5.2 developer pack from. Even after rebooting, both VS Code and Rider keep giving me the error that version 4.5 cannot be found.

    Here's the error VS Code gives me:


    I've also attempted manually setting the project version to 4.5.2, which seems to work for both editors, however every time I open Unity the version is set back to 4.5, and VS Code and Rider stop working again.
     
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Got it. If you believe this to be a bug (it may very well be) and you can reproduce perhaps on a second machine also, then I would encourage you to open a bug report from the Editor.
     
  5. shiMusa

    shiMusa

    Joined:
    Aug 30, 2018
    Posts:
    1
    I just had the same error. My solution:
    go to the "Assembly-CSharp.csproj" file and edit (line 16 in my case)
    Code (csharp):
    1. <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
    to
    Code (csharp):
    1. <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
    Save and Omnisharp should automatically update and work as expected.
    Unfortunately, you have to do this every time you add a C# file in Unity, so I guess it has to do with Unity setting the target-framework new...
     
    Yongho and Werxzy like this.
  6. cordlc

    cordlc

    Joined:
    Jul 27, 2018
    Posts:
    11
    In Unity 2018.3.0b6, I also have problems with Unity always setting the target framework to v4.5. It's too much of a pain for me to go and change it every single time, so I took the time to search how to get .net 4.5 (it was much more annoying than it should be):

    Inside the Window sdk archive, there's a link for the "Windows 8" SDK. See here:
    https://go.microsoft.com/fwlink/p/?LinkId=226658

    It doesn't say 4.5 anywhere in the description, but once you get into the install it contains exactly what you need. Ideally we have Unity set it to the proper framework version, but for me, this will do for now.
     
  7. NemoStein

    NemoStein

    Joined:
    Feb 17, 2014
    Posts:
    9
    I've managed to walk around the problem by copying my .NET v4.7.2 folder
    From
    C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2
    to
    C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5
    .
    This tricked the VSCode so far.
     
  8. lessice

    lessice

    Joined:
    Mar 8, 2017
    Posts:
    6
    This trick also work for me. Thanks!
     
  9. eterlan

    eterlan

    Joined:
    Sep 29, 2018
    Posts:
    177
    OMG!!!! I just keep google this issue three days! And uninstall my VScode and windows.....Really thanks you! it's smart haha.
     
  10. Blinkq

    Blinkq

    Joined:
    Apr 19, 2015
    Posts:
    21
    Thank you.
     
  11. DrSpritz

    DrSpritz

    Joined:
    Oct 6, 2013
    Posts:
    29
    it works for me, thanks!
     
  12. CrowbarSka

    CrowbarSka

    Joined:
    Dec 15, 2009
    Posts:
    192
    Thanks for the fix, I was hit by this issue too.

    I see that the issue is fixed in 2019.1, but will the fix be patched into a subsequent 2018.3.X update for those of us who don't intend to use 2019 for certain projects?
     
  13. Ne0mega

    Ne0mega

    Joined:
    Feb 18, 2018
    Posts:
    755
    I think this may be the issue I am running into as well. I could not tell if it occurred due to upgrading to 2018.3 or installing an asset store asset, (I did both at about the same time) but my visual studio just hasn't been right since. :/ Since I only started coding a year ago, I am terrified of monkeying around with this more.

    It just seems Unity and VisualStudio are not communicating, although Unity will not compile if there are errors... Visual Studio does not highlight those errors anymore, or colorize words like "monobehaviour".

    Hey, I only have a folder for v3.5... what gives? How do I get 4.5? which one should I download?

    Edit: well I tried, apparently I already have .NET 4.7.2 installed.
     
    Last edited: Jan 8, 2019
  14. CrowbarSka

    CrowbarSka

    Joined:
    Dec 15, 2009
    Posts:
    192
    @Ne0mega: I had the same issue. If you have 4.7.2 installed you can't install 4.5.

    The solution I found was to install the 4.5.2 developer pack instead:
    https://dotnet.microsoft.com/download/thank-you/net452-developer-pack
    (Note: I don't really know what this is, or what the difference is??? But it was suggested on another thread that I can't find now, and it worked for me!)

    Installing that will create the directory at:
    C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2

    Then rename that last folder and delete the ".2" part to make it "v4.5".
     
    ghostitos and Zaine7673 like this.
  15. Ne0mega

    Ne0mega

    Joined:
    Feb 18, 2018
    Posts:
    755
    Thanks for the help, but that wont install on my version of windows.

    Anyways, luckily, I store multiple copies of my projects, so I just fired up an older version, and everything is good.. ...meaning probably that it is some dorked setting in Unity I can't figure out.

    For future travelers:
    I went through a lot of scary stuff, and in the end, it was the same. :/
    I think I have the devpack installed now, but I have no idea what that means.

    I reverted to .Net3.5 for now.
     
    Last edited: Jan 14, 2019
    ghostitos likes this.
  16. eterlan

    eterlan

    Joined:
    Sep 29, 2018
    Posts:
    177
    Mac also has this problem, however, after installing mono, it flee away.
     
  17. SeanCheung

    SeanCheung

    Joined:
    Jan 27, 2014
    Posts:
    2
    No need to make a copy, just make a directory junction(like symlink).

    Open cmd as administrator:

    cd "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework"

    Grab what you have. For me its "v4.7.2".
    Do the trick:

    mklink /J v4.5 v4.7.2

    Enjoy!
     
  18. TekZ

    TekZ

    Joined:
    Oct 21, 2012
    Posts:
    1
    Worked well for me. Thank you
     
  19. Yongho

    Yongho

    Joined:
    Aug 17, 2015
    Posts:
    4
    This is the Best Solution.
     
  20. bumbu

    bumbu

    Joined:
    Sep 14, 2015
    Posts:
    16
    It seems that you have to download the "developer pack" in order it to work with omnisharp, even though you already have .NET Framework 4.x installed. So I downloaded all required dev packs from https://dotnet.microsoft.com/download/thank-you/net471-developer-pack
    and those dev packs will create the folder in C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.x
     
    MarioBag likes this.
  21. MarioBag

    MarioBag

    Joined:
    Feb 9, 2015
    Posts:
    1

    So far this is the only solution that solved that problem for me. Thanks
     
  22. AkselSky

    AkselSky

    Joined:
    Dec 3, 2015
    Posts:
    11
    2019
    Problem still persists
    Don't know who to blame either Unity, VS Code or .NET Framework
    Copy/Paste existing max version of .NET Framework (in my case 4.8) in
    Code (folder):
    1. C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\
    and renaming it to the target .NET Framework wanted by Assembly-CSharp (what is 4.7.1) - "solve" the problem, IntelliSense works properly.

    But this kind of fixing feels so wrong o_O
     
    CrowbarSka likes this.
  23. keisse12

    keisse12

    Joined:
    Oct 19, 2021
    Posts:
    1
    Doing totally unrelated stuff to Unity but also needed to have 4.5. This man is an unsung hero. Although I went for 4.5.2 copypasta. Hope it keeps working.