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

Question Error detecting Visual Studio installations

Discussion in '2020.1 Beta' started by SiqiLi, Jun 1, 2020.

  1. SiqiLi

    SiqiLi

    Joined:
    Oct 17, 2018
    Posts:
    7
    I got this error no matter I upgrade an old version project or create a new project.
    I'm using Visual Studio 16.6.
    Thanks for any help.

    Error detecting Visual Studio installations: System.ArgumentException: JSON parse error: Invalid escape character in string.
    at (wrapper managed-to-native) UnityEngine.JsonUtility.FromJsonInternal(string,object,System.Type)
    at UnityEngine.JsonUtility.FromJson (System.String json, System.Type type) [0x0005c] in <17042f127c734f4fbba6ce912ba37f00>:0
    at UnityEngine.JsonUtility.FromJson[T] (System.String json) [0x00001] in <17042f127c734f4fbba6ce912ba37f00>:0
    at Microsoft.Unity.VisualStudio.Editor.Discovery+VsWhereResult.FromJson (System.String json) [0x00000] in E:\SiqiLI\Unity Projects\New Unity Project\Library\PackageCache\com.unity.ide.visualstudio@2.0.1\Editor\Discovery.cs:93
    at Microsoft.Unity.VisualStudio.Editor.Discovery.QueryVsWhere () [0x0009a] in E:\SiqiLI\Unity Projects\New Unity Project\Library\PackageCache\com.unity.ide.visualstudio@2.0.1\Editor\Discovery.cs:160
    at Microsoft.Unity.VisualStudio.Editor.Discovery+<GetVisualStudioInstallations>d__0.MoveNext () [0x0002e] in E:\SiqiLI\Unity Projects\New Unity Project\Library\PackageCache\com.unity.ide.visualstudio@2.0.1\Editor\Discovery.cs:22
    at System.Collections.Generic.LargeArrayBuilder`1[T].AddRange (System.Collections.Generic.IEnumerable`1[T] items) [0x0005e] in <351e49e2a5bf4fd6beabb458ce2255f3>:0
    at System.Collections.Generic.EnumerableHelpers.ToArray[T] (System.Collections.Generic.IEnumerable`1[T] source) [0x00033] in <351e49e2a5bf4fd6beabb458ce2255f3>:0
    at System.Linq.Enumerable.ToArray[TSource] (System.Collections.Generic.IEnumerable`1[T] source) [0x00018] in <351e49e2a5bf4fd6beabb458ce2255f3>:0
    at Microsoft.Unity.VisualStudio.Editor.VisualStudioEditor..cctor () [0x00000] in E:\SiqiLI\Unity Projects\New Unity Project\Library\PackageCache\com.unity.ide.visualstudio@2.0.1\Editor\VisualStudioEditor.cs:36
    UnityEngine.Debug:Log(Object)
    Microsoft.Unity.VisualStudio.Editor.VisualStudioEditor:.cctor() (at Library/PackageCache/com.unity.ide.visualstudio@2.0.1/Editor/VisualStudioEditor.cs:42)
    System.Activator:CreateInstance(Type)
    Unity.CodeEditor.CodeEditor:get_Current()
    Unity.CodeEditor.CodeEditor:get_CurrentEditor()
    UnityEditor.VisualStudioIntegration.UnityVSSupport:IsDefaultExternalCodeEditor()
     
  2. SiqiLi

    SiqiLi

    Joined:
    Oct 17, 2018
    Posts:
    7
    Visual Studio doesn't work properly either. And I can't save any changes to scenes.
     
  3. John_MSFT

    John_MSFT

    Microsoft Employee

    Joined:
    Feb 21, 2018
    Posts:
    118
    @SiqiLi

    Where is Visual Studio installed on your machine? If it's not in the standard C:/Program Files/... location or the path contains some unexpected characters in the path, that could be related.

    The next step would be to capture the output of this command from the command line:

    .\Library\PackageCache\com.unity.ide.visualstudio@2.0.1\Editor\VSWhere\vswhere.exe -prerelease -format json

    If you can share the json output it will help us determine where the issue is.
     
    Last edited: Jun 3, 2020
  4. sailro

    sailro

    Microsoft

    Joined:
    Jul 30, 2014
    Posts:
    167
    @SiqiLi,

    From your Unity project, could you run the following in a command line ?

    .\Library\PackageCache\com.unity.ide.visualstudio@2.0.1\Editor\VSWhere\vswhere.exe -prerelease -format json > output.json


    (be sure to replace @2.0.1 with your exact VS package version)

    And send us this output.json file please.

    Also could you run the following in a command line:

    systeminfo > output.txt


    And send us this output.txt file please.

    Thank you!
     
  5. unity_nFlYoJzxHXOAuQ

    unity_nFlYoJzxHXOAuQ

    Joined:
    Apr 21, 2020
    Posts:
    1
    I also have the same problem. Could anyone help me? Thank you so much in advance.
    The output.json is:

    Code (JavaScript):
    1. [
    2.   {
    3.     "instanceId": "22fd53dd",
    4.     "installDate": "2020-04-10T05:14:56Z",
    5.     "installationName": "VisualStudio/16.6.3+30225.117",
    6.     "installationPath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community",
    7.     "installationVersion": "16.6.30225.117",
    8.     "productId": "Microsoft.VisualStudio.Product.Community",
    9.     "productPath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\Common7\\IDE\\devenv.exe",
    10.     "isPrerelease": false,
    11.     "displayName": "Visual Studio Community 2019",
    12.     "description": " IDE",
    13.     "channelId": "VisualStudio.16.Release",
    14.     "channelUri": "https://aka.ms/vs/16/release/channel",
    15.     "enginePath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\resources\\app\\ServiceHub\\Services\\Microsoft.VisualStudio.Setup.Service",
    16.     "releaseNotes": "https://go.microsoft.com/fwlink/?LinkId=660893#16.6.3",
    17.     "thirdPartyNotices": "https://go.microsoft.com/fwlink/?LinkId=660909",
    18.     "updateDate": "2020-07-01T06:02:03.3108024Z",
    19.     "catalog": {
    20.       "buildBranch": "d16.6",
    21.       "buildVersion": "16.6.30225.117",
    22.       "id": "VisualStudio/16.6.3+30225.117",
    23.       "localBuild": "build-lab",
    24.       "manifestName": "VisualStudio",
    25.       "manifestType": "installer",
    26.       "productDisplayVersion": "16.6.3",
    27.       "productLine": "Dev16",
    28.       "productLineVersion": "2019",
    29.       "productMilestone": "RTW",
    30.       "productMilestoneIsPreRelease": "False",
    31.       "productName": "Visual Studio",
    32.       "productPatchVersion": "3",
    33.       "productPreReleaseMilestoneSuffix": "1.0",
    34.       "productSemanticVersion": "16.6.3+30225.117",
    35.       "requiredEngineVersion": "2.6.2111.5687"
    36.     },
    37.     "properties": {
    38.       "campaignId": "1350850476.1586495104",
    39.       "canceled": "0",
    40.       "channelManifestId": "VisualStudio.16.Release/16.6.3+30225.117",
    41.       "nickname": "",
    42.       "setupEngineFilePath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\vs_installershell.exe"
    43.     }
    44.   }
    45. ]
    46.  
    I have also uploaded output.txt of my systeminfo
     

    Attached Files:

    Last edited: Jul 25, 2020
  6. John_MSFT

    John_MSFT

    Microsoft Employee

    Joined:
    Feb 21, 2018
    Posts:
    118
    @unity_nFlYoJzxHXOAuQ

    Open Unity Editor > Windows > Package Manager and find the "Visual Studio" package that's installed in your project. Update it to version 2.0.2.
     
    jess169 and BadBBilly like this.
  7. Jiaoan

    Jiaoan

    Joined:
    Jul 6, 2018
    Posts:
    2
    I find the solution to fix the problem, the link below :
    https://qiita.com/0x536f/items/9e6fb90f4002d2b1f4d2
    although it's wrote in Japanese, but i think is easy to fellow the step to fix it.

    go to your pacckage cache folder and find the Discovery.cs
    eq. Packages/com.unity.ide.visualstudio/Editor/Discovery.cs

    and change

    Arguments = "-prerelease -format json"

    to

    Arguments = "-prerelease -format json -utf8",

    and save.
     
  8. tacticalreindeer

    tacticalreindeer

    Joined:
    Aug 16, 2020
    Posts:
    5
    @Jiaoan
    but the file will be rebuild when i open the project
    The package cache was invalidated and rebuilt because the following immutable asset(s) were unexpectedly altered:
    Packages/com.unity.ide.visualstudio/Editor/Discovery.cs
     
  9. SiqiLi

    SiqiLi

    Joined:
    Oct 17, 2018
    Posts:
    7
    Sorry for the late reply. I got back to work on 2019.4 and forgot this thread.
    I've tried to update to 2020.1.2f1 and Visual Studio package 2.0.2, but this problem still exists.
    The json output file and systeminfo output file are attached below.
    Maybe the problem is that I'm using Japanese as my system language?
    Thank you for your help!
     

    Attached Files:

  10. tacticalreindeer

    tacticalreindeer

    Joined:
    Aug 16, 2020
    Posts:
    5
    got same problem after i try to upgrade my project to newest version
    cant even open a script
    pls help
     
  11. sailro

    sailro

    Microsoft

    Joined:
    Jul 30, 2014
    Posts:
    167
    @SiqiLi thanks, could you run one extra command please?

    .\Library\PackageCache\com.unity.ide.visualstudio@2.0.2\Editor\VSWhere\vswhere.exe -prerelease -format json -utf8 > output.utf8.json


    We have a fix but we want to double check using your output.

    Thanks!
     
  12. Jiaoan

    Jiaoan

    Joined:
    Jul 6, 2018
    Posts:
    2
    @sailro hi, i have same problem too. there's my output.json and output.utf8.json, .json extension is not support for upload, so i change it to .txt
     

    Attached Files:

  13. sailro

    sailro

    Microsoft

    Joined:
    Jul 30, 2014
    Posts:
    167
    Thanks @Jiaoan. Confirmed. I double checked with your exports and this issue will be fixed with VS Editor package v2.0.3. We don't have a release date yet, but we'll work with Unity to publish it.

    cc @John_MSFT
     
  14. SiqiLi

    SiqiLi

    Joined:
    Oct 17, 2018
    Posts:
    7
    Sure.
    Here is the output json file.
    Thank you!
     

    Attached Files:

  15. sailro

    sailro

    Microsoft

    Joined:
    Jul 30, 2014
    Posts:
    167
    Thanks @SiqiLi. Confirmed. This issue will be fixed with VS Editor package v2.0.3.
     
  16. SiqiLi

    SiqiLi

    Joined:
    Oct 17, 2018
    Posts:
    7
    That's great! Thank you.
     
  17. marlene8810

    marlene8810

    Joined:
    Sep 7, 2020
    Posts:
    1
    sorry,I have same problem.
    Hope it can fix it soon
    qwq
     

    Attached Files:

  18. imabusayed

    imabusayed

    Joined:
    Sep 16, 2020
    Posts:
    1
    I stuck here... And I Can't Use Code in my project .. Start Learning Bolt now, Please fix this problem .. Did every possible thing, Even reinstall my windows but still not working :(
     
  19. sailro

    sailro

    Microsoft

    Joined:
    Jul 30, 2014
    Posts:
    167
    Hello @imabusayed, we think this issue was fixed with VS Editor Package v2.0.3. Please use the Unity package manager to update this component.

    Thanks!
     
  20. BentNai1

    BentNai1

    Joined:
    Apr 20, 2020
    Posts:
    2
    I'm having a similar issue, but I'm using Visual Studio Code, rather than Visual Studio. I am very new, please forgive me. ^^'

    I do not get auto-fill resources when editing my code in VSC. I can open the script, and it will seemingly highlight correctly, but it otherwise doesn't recognize what I type. Unity itself spits out this error message when I start:


    Error detecting Visual Studio installations: System.ArgumentNullException: Value cannot be null.
    Parameter name: input
    at System.Version.Parse (System.String input) [0x00003] in <fb001e01371b4adca20013e0ac763896>:0
    at Microsoft.Unity.VisualStudio.Editor.Discovery+VsWhereResult+<ToVisualStudioInstallations>d__2.MoveNext () [0x00047] in C:\Users\eatto\Desktop\My First Games\Project 2\Library\PackageCache\com.unity.ide.visualstudio@2.0.3\Editor\Discovery.cs:100
    at Microsoft.Unity.VisualStudio.Editor.Discovery+<GetVisualStudioInstallations>d__0.MoveNext () [0x00071] in C:\Users\eatto\Desktop\My First Games\Project 2\Library\PackageCache\com.unity.ide.visualstudio@2.0.3\Editor\Discovery.cs:22
    at System.Collections.Generic.LargeArrayBuilder`1[T].AddRange (System.Collections.Generic.IEnumerable`1[T] items) [0x0005e] in <351e49e2a5bf4fd6beabb458ce2255f3>:0
    at System.Collections.Generic.EnumerableHelpers.ToArray[T] (System.Collections.Generic.IEnumerable`1[T] source) [0x00033] in <351e49e2a5bf4fd6beabb458ce2255f3>:0
    at System.Linq.Enumerable.ToArray[TSource] (System.Collections.Generic.IEnumerable`1[T] source) [0x00018] in <351e49e2a5bf4fd6beabb458ce2255f3>:0
    at Microsoft.Unity.VisualStudio.Editor.VisualStudioEditor..cctor () [0x00000] in C:\Users\eatto\Desktop\My First Games\Project 2\Library\PackageCache\com.unity.ide.visualstudio@2.0.3\Editor\VisualStudioEditor.cs:36
    UnityEngine.Debug:Log(Object)
    Microsoft.Unity.VisualStudio.Editor.VisualStudioEditor:.cctor() (at Library/PackageCache/com.unity.ide.visualstudio@2.0.3/Editor/VisualStudioEditor.cs:42)
    System.Activator:CreateInstance(Type)
    Unity.CodeEditor.CodeEditor:get_Current()
    Unity.CodeEditor.CodeEditor:get_CurrentEditor()
    UnityEditor.VisualStudioIntegration.UnityVSSupport:IsDefaultExternalCodeEditor()



    I couldn't figure out where the command line in Unity is, to put in the command you suggested sailro - sorry!

    I've pulled my hair out on this for a while, lol, it'll be good to figure out what I'm doing wrong. Thanks for any help in this! ^^

    *edit*

    I updated my packages to the most recent versions, VSCE to 1.2.2, VSE to 2.0.3 ; in VSC I have a host of extensions installed from the Marketplace:
    C#
    C# FixFormat
    Debugger for Unity
    Unity Tools

    And a few others for HTML projects that probably have no bearing here. I notice that Unity Debugger in particular asks me to perform steps to set it up, using buttons I do not see. I'm not certain if this is related, if not please ignore, I'm just trying to provide any information that I think may be relevant. ^^'
     
  21. sailro

    sailro

    Microsoft

    Joined:
    Jul 30, 2014
    Posts:
    167
    Visual Studio package is for Visual Studio only (not VS Code).

    For Visual Studio Code you have to use the Visual Studio Code package which is maintained by Unity.
     
  22. tacticalreindeer

    tacticalreindeer

    Joined:
    Aug 16, 2020
    Posts:
    5
    newest version did not solve the problem
    i did check my package manager
    neither i know how to use command line
    stuck there for so long
    please somehow reply
     
  23. carmofin

    carmofin

    Joined:
    May 13, 2017
    Posts:
    116
    I updated Visual Studio 2017 and that seems to have resolved the exception.
     
  24. tacticalreindeer

    tacticalreindeer

    Joined:
    Aug 16, 2020
    Posts:
    5
    update: VS code do solve the problem
    so sad still no one gonna reply me...qwq y
     
  25. Ktulian

    Ktulian

    Joined:
    Apr 6, 2014
    Posts:
    8
    I hear ya! I had a game half built (ugly functional) and all the systems depreciated. Nothings worked right since, terrible support, 2 years waiting for a stable build, WTF unity!?
     
  26. Ktulian

    Ktulian

    Joined:
    Apr 6, 2014
    Posts:
    8
    Why would unity default to a paid service when there's a free option available? Smells like a fishy back end deal to take advantage of people; pretty gross. On the plus side their forcing me to use another product so I guess it's what you get.
     
  27. Serrano

    Serrano

    Joined:
    Dec 22, 2013
    Posts:
    1
    I discovered this thread as I experienced the same issue today... I fixed it by removing the french language setting from my VS2019 install and switching it to english laguage. I've just lost one day so I guess I'm "kind of lucky". I hope it might help some of you.

    https://agirlamonggeeks.com/2019/03...age-in-visual-studio-2019-after-installation/
    is a pretty cool link if you wonder how to change VS2019 language on an installed version.
     
    Last edited: Apr 27, 2021
  28. Balthazaar

    Balthazaar

    Joined:
    Dec 26, 2021
    Posts:
    1
    So, I was running 5.6.1f1 before and when I started a new project I couldn't get my Tilemaps to work (they weren't showing under the 2D Object menu in the Hierarchy view). When opening an older project with tilemaps there were script errors when choosing these objects.

    So, I uninstalled Unity and reinstalled the latest version: 2020.3.25f1

    Now I'm getting the following error in the console, after starting a new project:

    Error detecting Visual Studio installations: System.ArgumentNullException: Value cannot be null.

    It seems Unity can't detect Visual Studio. But I have no clue how to fix it. Googling got me to this thread, so hoping to get some help here.

    Thanks in advance.
     
  29. i-n-g-o

    i-n-g-o

    Joined:
    Mar 10, 2020
    Posts:
    4
    I just ran into the same issue with 2021.2.6f1 on Windows.

    In my case it was a single-quote ' in the file-path of the project: seems Unity can not find vswhere.exe in this case.
    Removing the single-quote from the path resolved the issue for me.

    This is not happening on macos.
     
  30. Proandrewmants

    Proandrewmants

    Joined:
    May 4, 2020
    Posts:
    2
    I just updated my Unity hoping to fix some issues and got here as well. The error that pops up is:

    Error detecting Visual Studio installations: System.ComponentModel.Win32Exception (0x80004005): ApplicationName='D:\Edric's Database\Edric Project\Projects\Unity Studies\New HighGround\Library\PackageCache\com.unity.ide.visualstudio@2.0.12\Editor\VSWhere\vswhere.exe', CommandLine='-prerelease -format json -utf8', CurrentDirectory='', Native error= The system cannot find the file specified.

    Still finding solution

    Unity 2021.2.7f1
     
  31. Shinugami

    Shinugami

    Joined:
    Oct 17, 2012
    Posts:
    54
    I have the same problem as of about a month ago (December 2021),
    For privacy I have abbreviated the file address with: [AddressForDirectoryStructureHere].
    I can load scripts from Unity by clicking on them and thereby opening them in Visual studio however the link between Unity and VisualStudio seems to be broken and so the VS editor doesn't work for the class structures so it's pretty much useless.

    Code (CSharp):
    1. Error detecting Visual Studio installations: System.ComponentModel.Win32Exception (0x80004005): ApplicationName='[AddressForDirectoryStructureHere]\PackageCache\com.unity.ide.visualstudio@2.0.12\Editor\VSWhere\vswhere.exe', CommandLine='-prerelease -format json -utf8', CurrentDirectory='', Native error= The system cannot find the file specified.
    ***Update: Have learned that this error occurs in regards to this:
    Erroneous version = com.unity.ide.visualstudio@2.0.12
    Working version = com.unity.ide.visualstudio@2.0.11

    To help fix this problem, in the package manager, please make it possible to install earlier versions of the packages as I am not seeing anything. If I start a new project, the version is 2.0.11 however if I update that and then decide I want to remove that package and install the earlier version - after removing the package, the package becomes locked and cannot be removed - even if it is unlocked. This is an extremely unfriendly user-interface. Please fix this so that it functions as intended.

    *** Update 2:
    I figure I best explain how I solved this problem that plagued me for about a month.
    There are two files in your [Packages] folder called [manifest.json] and [packages-lock.json].
    In the [manifest.json] : replace the text
    Code (CSharp):
    1. "com.unity.ide.visualstudio": "2.0.12",
    with
    Code (CSharp):
    1. "com.unity.ide.visualstudio": "2.0.11",
    In the [packages-lock.json] file, replace the text:
    Code (CSharp):
    1. "com.unity.ide.visualstudio": {
    2.       "version": "2.0.12",
    3.       "depth": 0,
    4.       "source": "registry",
    5.       "dependencies": {
    6.         "com.unity.test-framework": "1.1.9"
    7.       },
    8.       "url": "https://packages.unity.com"
    9.     },
    Replace it so that it looks like this:
    Code (CSharp):
    1. "com.unity.ide.visualstudio": {
    2.       "version": "2.0.11",
    3.       "depth": 0,
    4.       "source": "registry",
    5.       "dependencies": {
    6.         "com.unity.test-framework": "1.1.9"
    7.       },
    8.       "url": "https://packages.unity.com"
    9.     },
    And that completely solves the problem with the error message that I was getting in regards to VS and Unity.
    Update: 25/02/2022: Any update after <visualstudio@2.0.12> works. Any project that I had that used visualstudio@2.0.12 would have errors: so I just update it to the newest version and that fixed the problem. When visualstudio@2.0.12 was the newest version: I had to stick to visualstudio@2.0.11 to remain error free.
     
    Last edited: Feb 24, 2022
  32. i-n-g-o

    i-n-g-o

    Joined:
    Mar 10, 2020
    Posts:
    4

    You got a single-quote in your path: ApplicationName='D:\Edric's Database\...
    Try to remove your single-quote from the path, or move your project somewhere else and try again.

    Removing a single-quote solved the issue for me.
     
  33. i-n-g-o

    i-n-g-o

    Joined:
    Mar 10, 2020
    Posts:
    4
  34. Reappearance

    Reappearance

    Joined:
    Aug 12, 2020
    Posts:
    1
    Hi,

    I'd like to report that I've also run into this issue after upgrading to 2021.2.8f1 on Windows 10. The project would run into issues when building as well.The apostrophe in the project path (not just the project name, but all the folders leading up to it as well) was the cause, and removing it fixed everything immediately.

    tl;dr: removing all apostrophes from your project's path seems to be the quickest fix until the bug is gone
     
    lukettia, Evallis and Westland like this.
  35. Westland

    Westland

    Joined:
    Jan 26, 2015
    Posts:
    27
    One more with this issue.

    Very curious the apostrophe's the culprit. This was a project which was initially made with an apostrophe in the project's name, then remade under the same name (with the apostrophe) in HDRP, then remade a second time in the built-in (as was the first) - and only the last time around was the apostrophe an issue, giving the error.

    Removing it from the project folder worked though.
    Running VS Code here too.
     
    Evallis likes this.
  36. unity_56hUXEerkxvMOQ

    unity_56hUXEerkxvMOQ

    Joined:
    Aug 3, 2022
    Posts:
    1
    I fix my problem by

    Step 1: Replacing "Library\PackageCache\com.unity.ide.visualstudio@2.0.16 " with an older version from my backups in my case
    "Library\PackageCache\com.unity.ide.visualstudio@2.0.3"

    Step 2:
    in the file: \Packages.manifest.json
    "com.unity.ide.visualstudio": "2.0.16"

    change it to
    "com.unity.ide.visualstudio": "2.0.3"

    Step 3:
    in the file: \Packages.packages-lock.json

    "com.unity.ide.visualstudio": {
    "version": "2.0.16",
    "depth": 0,
    "source": "registry",
    "dependencies": { "com.unity.test-framework": "some version I forgot "},
    "url": "https://packages.unity.com"
    },

    change it to

    "com.unity.ide.visualstudio": {
    "version": "2.0.3",
    "depth": 0,
    "source": "registry",
    "dependencies": {},
    "url": "https://packages.unity.com"
    },

    I hope it works for you as well
     
  37. lukettia

    lukettia

    Joined:
    Jun 7, 2019
    Posts:
    1
    If you were in front of me I would F***ing kiss you.
     
    Westland likes this.