Copied from VSO ID: 1068111
A few days ago I was attempting to build/deploy a web site to a subfolder of C:\inetpub\wwwroot. After using Internet Information Services (IIS) Manager to create the folder, I tried using Visual Studio (2019) to build the web site. My 1st attempt failed, and I was instructed - I believe by a Visual Studio diagnostic - that I would have to run Visual Studio in Administrative mode. I tried again after restarting Visual Studio in Administrative Mode, and the Build was successful. But, from then on I was unable to reopen Visual Studio without Administrative Mode: the diagnostic was displayed in an ordinary popup box with an OK button, and with the text “Cannot write to folder C:\user\sncole\AppData\Local\Temp\WPF. Access is denied”.
(It is possible that I caused this error when I tried to reopen Visual Studio before closing it while it was in Administrative Mode.)
I used Google Search extensively to try to find some other user with a similar experience; no luck. Finally - a day later - I stumbled on a work-around. I tried to open C:\user\sncole\AppData\Local\Temp\WPF with Windows Explorer; Windows Explorer similarly informed me that access was denied, but it asked me whether I wanted to override the access denial. I said “yes”, and I was allowed to view the contents of C:\user\sncole\AppData\Local\Temp\WPF. Since then I no longer need Administrative mode to open Visual Studio.
The issue here is that a WPF folder is getting created in the temp directly with wrong ACLs.
Maybe it is Prevented from opening visual studio because of inability to write to folder WPF problem.
@gomathip02 Could you try to write this code to your main method?
Environment.SetEnvironmentVariable("TEMP", tempFolder);
Environment.SetEnvironmentVariable("TMP", tempFolder);
The tempFolder is your custom folder full path.
And I do not know why the C:\user\sncole\AppData\Local\Temp\WPF folder can not be wrote. This code can only change the Path.TempPath to your folder
@lindexi @gomathip02 is a PM on the WPF team, this is just copied here from an internal bug.
@rladuc Thank you and sorry.
@lindexi Nothing to be sorry about, I just wanted to be sure you weren't trying to help someone who wasn't going to need it. Definitely appreciate the attempt!
It probably shouldn't be using a hard-coded name for its temporary directory.