"Could not load file or assembly 'Microsoft.CSharp'" when debugging with impersonate = true

0

I have a .net MVC app that has impersonate set to true in the web.config:

<identity impersonate="true" userName="Administrator" password="pAsswOrd" />

Everything worked fine on my windows 7 computer, but I just got a windows 10 computer. I pulled down this app from the Git repo and when I try to debug I get:

Could not load file or assembly 'Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, 
PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Either a required impersonation level 
was not provided, or the provided impersonation level is invalid. (Exception from HRESULT: 
0x80070542)

The only solution so far I can find is to open visual studio as an administrator, and then it debugs fine. However this is annoying to have to do this considering this was not an issue on my old pc.

I have read the possible solution is to add read/write permissions to the C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files folder for the Administrator user (I even tried adding full permissions to the Everyone user), but it is not helping.

The project is using .net framework 4.7.2.

What is the solution to allow debugging a site that has impersonation enabled (without opening VS as an administrator)?

c#
asp.net-mvc
windows-10
visual-studio-2019
.net-4.7.2
asked on Stack Overflow Mar 25, 2020 by lucky.expert

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0