Error detecting Visual Studio installations

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+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.LargeArrayBuilder1[T].AddRange (System.Collections.Generic.IEnumerable1[T] items) [0x0005e] in <351e49e2a5bf4fd6beabb458ce2255f3>:0
at System.Collections.Generic.EnumerableHelpers.ToArray[T] (System.Collections.Generic.IEnumerable1[T] source) [0x00033] in <351e49e2a5bf4fd6beabb458ce2255f3>:0 at System.Linq.Enumerable.ToArray[TSource] (System.Collections.Generic.IEnumerable1[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()

Visual Studio doesn’t work properly either. And I can’t save any changes to scenes.

@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.

@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!

I also have the same problem. Could anyone help me? Thank you so much in advance.
The output.json is:

[
  {
    "instanceId": "22fd53dd",
    "installDate": "2020-04-10T05:14:56Z",
    "installationName": "VisualStudio/16.6.3+30225.117",
    "installationPath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community",
    "installationVersion": "16.6.30225.117",
    "productId": "Microsoft.VisualStudio.Product.Community",
    "productPath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\Common7\\IDE\\devenv.exe",
    "isPrerelease": false,
    "displayName": "Visual Studio Community 2019",
    "description": " IDE",
    "channelId": "VisualStudio.16.Release",
    "channelUri": "https://aka.ms/vs/16/release/channel",
    "enginePath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\resources\\app\\ServiceHub\\Services\\Microsoft.VisualStudio.Setup.Service",
    "releaseNotes": "https://go.microsoft.com/fwlink/?LinkId=660893#16.6.3",
    "thirdPartyNotices": "https://go.microsoft.com/fwlink/?LinkId=660909",
    "updateDate": "2020-07-01T06:02:03.3108024Z",
    "catalog": {
      "buildBranch": "d16.6",
      "buildVersion": "16.6.30225.117",
      "id": "VisualStudio/16.6.3+30225.117",
      "localBuild": "build-lab",
      "manifestName": "VisualStudio",
      "manifestType": "installer",
      "productDisplayVersion": "16.6.3",
      "productLine": "Dev16",
      "productLineVersion": "2019",
      "productMilestone": "RTW",
      "productMilestoneIsPreRelease": "False",
      "productName": "Visual Studio",
      "productPatchVersion": "3",
      "productPreReleaseMilestoneSuffix": "1.0",
      "productSemanticVersion": "16.6.3+30225.117",
      "requiredEngineVersion": "2.6.2111.5687"
    },
    "properties": {
      "campaignId": "1350850476.1586495104",
      "canceled": "0",
      "channelManifestId": "VisualStudio.16.Release/16.6.3+30225.117",
      "nickname": "",
      "setupEngineFilePath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\vs_installershell.exe"
    }
  }
]

I have also uploaded output.txt of my systeminfo

6129368–668192–output.txt (3.58 KB)

@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.

3 Likes

I find the solution to fix the problem, the link below :

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.

@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

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!

6211817–682595–output.txt (5.55 KB)
6211817–682598–output.json.txt (3.95 KB)

got same problem after i try to upgrade my project to newest version
cant even open a script
pls help

@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!

@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

6254781–689697–output.txt (2 KB)
6254781–689700–output.utf8.txt (2.02 KB)

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

Sure.
Here is the output json file.
Thank you!

6265005–691491–output.utf8.json.txt (3.99 KB)

Thanks @SiqiLi . Confirmed. This issue will be fixed with VS Editor package v2.0.3.

That’s great! Thank you.

sorry,I have same problem.
Hope it can fix it soon
qwq


6286835--695186--{B7027B1D-3086-47AD-8E49-7E91907C17A4}.png.jpg

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 :frowning:

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!

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. ^^’