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. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

VS Code Error [SOLVED]

Discussion in 'Scripting' started by Nicokam, Aug 20, 2020.

  1. Nicokam

    Nicokam

    Joined:
    May 28, 2020
    Posts:
    62
    I suddenly got this warning today from VS Code of my Unity project I have been working for months making me unable to keep programming my c# scripts, because it no longer has autocompletes terms from Mono develop or any other c# words.

    upload_2020-8-20_16-27-21.png

    It has something to do with Omnisharp. I found some things online but nothing seamed to work and it is a very confusing subject I don't seem to get.

    Can someone help me with clear instructions please?
     
  2. pantang

    pantang

    Joined:
    Sep 1, 2016
    Posts:
    182
    Not to sure about that error the output might help but for your auto complete woes there should be a hidden folder called .vs in your project folder. delete it and reload the project normally fixes missing autocomplete problems. If its unity wide then you need to set the external editor to visual studio in your project settings.
     
  3. Nicokam

    Nicokam

    Joined:
    May 28, 2020
    Posts:
    62
    Erased the folder and restarted unity and it was not solved.

    Also did set Visual Studio Code as the external editor again, just to make sure. That's the weird thing, I did that a long time ago and it was working just fine. It stopped working all of a sudden.

    I think it's important to say I use a Mac

    Parts of the error:

    [fail]: OmniSharp.MSBuild.ProjectLoader
    The reference assemblies for .NETFramework,Version=v4.7.1 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks

    [fail]: OmniSharp.MSBuild.ProjectManager
    Attempted to update project that is not loaded:
     
    NOT_A_ROBOT1101 likes this.
  4. Nicokam

    Nicokam

    Joined:
    May 28, 2020
    Posts:
    62
  5. Dextozz

    Dextozz

    Joined:
    Apr 8, 2018
    Posts:
    488
    Yeah, I dealt with this quite a lot. VSCode is just a garbage IDE, It's the worst thing I've ever used.

    - Try deleting the .sln file in your project
    - (< Unity 2020.1) Try going into Preferences > External Editors > Generate all .csproj files
    - (>= Unity 2020.1) Try going into Preferences > External Editors > Should be a button called "Regenerate ..." or something similar, click it.
    - Open any script via double click

    Or
    - Revert C# extension to a previous version

    Or
    - Give up and switch to a new IDE if you don't have to use VSCode.
     
    Aykutkaraca and Rneama like this.
  6. Nicokam

    Nicokam

    Joined:
    May 28, 2020
    Posts:
    62
    Thanks for the reply! Which IDE would you suggest?
     
  7. Dextozz

    Dextozz

    Joined:
    Apr 8, 2018
    Posts:
    488
    I would love to know the answer to that question as well.

    I heard people praising Ryder, but it's quite expensive. It does have a free trial for a month, I might check it out.
    Stick to regular Visual Studio if you can though. VSCode is common because it's 100% free so all tech companies are going for it, but it's inexcusably unpolished.
     
    Nicokam likes this.
  8. Teos

    Teos

    Joined:
    Jul 30, 2015
    Posts:
    2
    I just received this same issue, did not make any difference deleting and regenerating those project files.
    It was only after I downgraded VSCode C# extension from 1.23.1 to 1.23.0 that it started to work again.
     
  9. A_Sloane

    A_Sloane

    Joined:
    Aug 19, 2015
    Posts:
    10
    Same that Theos. After 1 hour trying to figure out a solution, the easiest thing to do was to downgrade to 1.23.0.
     
    Nicokam and Kurt-Dekker like this.
  10. SecondQuestGames

    SecondQuestGames

    Joined:
    Mar 9, 2017
    Posts:
    6
    I ran into this problem too but got it worked out after jumping through some hoops. Like others here mentioned, it turned out to be an issue with Microsoft/OmniSharp's C# extension for VS Code.

    Here's the full set of steps I ran through to fix it:
    1. Close out Unity.
    2. Delete all the VS Project files in your Unity project folder (.csproj, .sln, .vscode folder).
    3. Open VS Code, hit Ctrl+Shift+P and type `Disable Auto Updating Extensions`. This will stop Microsoft from auto-updating C# to a broken version.
    4. Find the C# extension in the list of your installed VS Code extensions, right click, then click "Install Another Version".
    5. Select v1.23.0 and let it install.
    6. Close out of VS Code.
    7. Open your Unity project, and the VS Project files will automatically be rebuilt.
    8. VS Code and Intellisense back to normal again.
     
    Lorrak, Pandazole, Rohinth and 3 others like this.
  11. airespt

    airespt

    Joined:
    Apr 7, 2016
    Posts:
    2
    I had a new breakage with VSC on linux this week.
    One day all was fine, next day, suddenly, VSC complains about all refs to code placed inside Plugins folder.

    In my case it seems Omnisharp was skip/ignoring the Assembly-CSharp-firstpass.csproj file.
    Downgrading C# extension from 1.23.3 to 1.23.0 fixed it. Thank you all.

    (Beware, looks like MS is pushing .Net CORE so hard, they are breaking stuff left and right.)
     
    Lorrak likes this.
  12. cosmicelysium

    cosmicelysium

    Joined:
    Jul 20, 2015
    Posts:
    4
    omg thank you so much. I tried so many things and this finally fixed the issue :)

    EDIT: There seem to be plenty of logged issues with the extension:
    https://github.com/OmniSharp/omnisharp-vscode/issues
     
    Last edited: Oct 15, 2020
  13. Jaakk0S

    Jaakk0S

    Joined:
    Apr 19, 2020
    Posts:
    48
    Thank you #TorchFireStudios and the rest, life savers you are! I clicked some update button without paying attention... boy, almost wasted a whole work day. MAN!

    Problem: Open VS Code, namespaces are screwed in a way that doesn't have much logic +1K errors with messages like .csproj files not found where they definitely are found.. all sorts of trouble that also seems to jump from on issue to another between restarts without much logic to it. In addition VS Code eats CPU time like a starved baboon on steroids, I mean on a scale from 0=working to 10=heroin-overdose we are at 9.9 nuclear catastrophy.
    Culprit: C# for Visual Studio Code 1.23.4 or .3 not even sure. This is the editor extension that understands C#.
    Fix: Downgrade option doesn't exist. 1. Uninstall, 2. download manually 1.23.0 VSIX file, 3. find "Install from VSIX" option, 4. Enjoy life again. Oh and 5. I also run "Extensions: Disable Auto Updating Extensions", figure that's necessary to avoid this in the future.
     
    Last edited: Oct 21, 2020
  14. NOT_A_ROBOT1101

    NOT_A_ROBOT1101

    Joined:
    Jun 18, 2020
    Posts:
    39
    Thanks, man! I struggled with this problem a lot and as it turns out, I forgot to do this.
     
    Nicokam likes this.
  15. stickygamessthlm

    stickygamessthlm

    Joined:
    Nov 12, 2020
    Posts:
    3
    Got this problem after updating Unity LTS. (Unity 2019.4.20f0 -> f1). The 1.23.0 downgrade solution didn't work for me though.

    After some more googling, came across this thread: https://forum.unity.com/threads/nam...space-unityengine-error-on-2019-3-2f1.831922/

    So I tried just changing the External Script Editor in Unity preferences to 'open by file extension', then closing both Unity and VSCode, then reopening and selecting VSCode again. Now it seems to work as it should with latest version of C# extension
     
    Lorrak and L_Bens_Up like this.
  16. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    827
    Downgrading to 1.23.0 solved the problem. Thanks a lot!
     
  17. SecondQuestGames

    SecondQuestGames

    Joined:
    Mar 9, 2017
    Posts:
    6
    Update for anyone else that runs across this problem...

    It turned out that this is a known compatibility issue between the C# extension in VS code, Mono/Omnisharp, and Unity. It's even listed prominently at the top of the C# extension's changelog:

    For Mono-based development (e.g. Unity) that requires full .NET framework, you need to set "omnisharp.useGlobalMono": "always". The current value of "auto" will remain "never" until Mono [URL='https://github.com/mono/mono/issues/20250']upgrades their bundled MSBuild version[/URL].


    So instead of downgrading to 1.23.0 (which also works but is outdated), you can instead just use their recommended solution:
    • In VS Code, open Settings
    • Search for "omnisharp use global"
    • Change Omnisharp: Use Global Mono setting to: "always"
    Then to make sure Unity recognizes the changes...
    • Close all Unity projects
    • Delete any .sln or .csproj files (Unity will recreate them)
    • Re-open a Unity project
    • Double click any script to have it open in VS code
    • Let the omnisharp compiler do its thing
    • Intellisense should now be working again
     
    Lorrak and peterpan2022 like this.
  18. tomaszminiewicz

    tomaszminiewicz

    Joined:
    Dec 30, 2021
    Posts:
    1
  19. Lorrak

    Lorrak

    Joined:
    Sep 17, 2019
    Posts:
    29
    this should be sticked somewhere in forum or thread created just for Vs code related problems :confused:
     
    thefallengamesstudio likes this.
unityunity