Visual Studio 2019 Illegal characters in path

Viewed 2557

Lately, I am having a persistent error message. The error message emerges in two conditions at least:

  1. After creating a new project (in c# or vb) in .NET Framework, when I right-click -> add... -> new item... the error message shows up. .NET Framework

Add item

error message

2- When I try to create a project (c# or vb) in .NET Core I get the same error message directly: NET Core

error

Even if I opened an old project, which works or worked fine, after that, when I try to add a new item I get the same error message. I have already reported this issue to Microsoft. But still no clear solution. Did anyone get the same problem? By the way, I have already tried many known tactics like clearing the cache in C:\Users\Salam\AppData\Local\Microsoft\VisualStudio\16.0_8c60507b And I tried to repair or uninstall then reinstall the product. All those tactics didn't help.

environment_variables

This is the full path of one of my old project, which already has a class. But right now I can not add a new class to it. Since it generates the same error message. The path I copied by right-clicking in VS on the project then choosing 'copy full path'. D:\Users\Salam\source\repos\test_windowsFormsApp2\test_windowsFormsApp2.sln

The location a copy-paste: C:\Users\Salam\source\repos

Edit: When I start the VS 2019 then I choose "continue without code". After that, from the menu, I click on File -> New -> File... I get the same error message "Ilegal characters in path". Or simply when I click from the keyboard "ctrl+n" I get the same error message.

1 Answers

You probably have an invalid system path (NOT user path, which you have shown at your last image), as I just got this bug and found a fix for it.

Apparently my system path had a path called <path to add>; https://i.imgur.com/asXvwjn.png. This is an invalid path, you can check for all paths by doing echo $env:path in PowerShell and then find a path that's invalid. Now you need to delete the invalid path. I don't know how to do it without downloading another software, but I used Rapid Environment Editor (launch with admin privileges or it'll only be read only) to delete.

Restart VS2019 and it should work

Related