0

Running the latest Visual Studio Code (v1.48.1 at the time of posting this) with C# Extension, I'm seeing this errors:

Razor.VSCode version 6.0.0-alpha.1.20418.9
...
[Error - 4:20:16 PM] Server initialization failed. 
Message: Internal Error - System.UnauthorizedAccessException: Access to the path 'c:\Users\UserName\Application Data' is denied.

I've tried reinstalling VS and all extensions but that didn't help.

Is anyone else seeing this? Is there a workaround?

noseratio
  • 2,743
  • 5
  • 20
  • 34
  • [I spent a considerable amount of time doing research into Visual Studio Code](https://superuser.com/questions/1481238/where-are-programs-usually-installed-for-a-particular-user/1481723#1481723). – Ramhound Aug 22 '20 at 09:55
  • @Ramhound it's a good insight, but in my case the folder is actually there (as a hard link), `dir /al` shows this: ` Application Data [C:\Users\UserName\AppData\Roaming]`. Everything worked a week or so ago. Something must have changed with the recent `Razor.VSCode` and/or VSCode updates. – noseratio Aug 22 '20 at 10:22
  • [You are using an Alpha version of Visual Studio Code.](https://devblogs.microsoft.com/aspnet/razor-support-in-visual-studio-code-now-in-preview/). You have also enabled an experimental feature. Since you have enabled a different editor, the location the editor uses will be different than the previous stable version of Visual Studio Code. Yes; That is an older article, but I still suspect, you have enabled an experimental feature. – Ramhound Aug 22 '20 at 10:26
  • 1
    [Here](https://github.com/dotnet/aspnetcore/issues) is how you report issues with the Razer tooling. What you describe shouldn't be happening. – Ramhound Aug 22 '20 at 10:36
  • It's a current release version (1.48.1) with the current release version of C# extension, not alfa. I've never explicitly enabled any experimental features or installed any canary builds. I do suspect it's local to my machine though. I'll file an issue if I can repro it under a fresh VM or Windows Sandbox. – noseratio Aug 22 '20 at 10:40

1 Answers1

2

A quick and dirty fix, as a note to my future self.

Running:

Icacls "%USERPROFILE%\Application Data"

Shows:

C:\Users\UserName\Application Data 
Everyone:(DENY)(S,RD)
NT AUTHORITY\SYSTEM:(I)(OI)(CI)(F)
BUILTIN\Administrators:(I)(OI)(CI)(F)
PC\UserName:(I)(OI)(CI)(F) 

I have no idea what user account Razor.VSCode runs under (if it's different from UserName at all), but removing Everyone from the above access list solved this problem. I had to repeat it for some other folders. This is not a proper fix as it may compromise the system's security, but I needed a quick fix:

Icacls "%USERPROFILE%\Application Data" /remove Everyone /t
noseratio
  • 2,743
  • 5
  • 20
  • 34