I have created a website which compiles successfully when I log-in using administrator but when I log-in using any other user, following error occurs.
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 administrator user is member of
- Acronis Remote Users
- Administrators
- Remote Desktop Users
while the other user is member of
- Acronis Remote users
- Administrators *
- IIS_IUSRS
- Remote Desktop Users
- SQLServerMSSQLUser$vm-tmp-abcd-1$MSSQLSERER
- Users
I am using
Windows Server 2008 R2 Enterprise with 64-bit Operating System
- Initially the other user didn't belong to administrators group. I added the administrators role to it but still I am getting the same error.
NOTE: It compiles the website successfully if I choose VS2010 to run as administrator.
This one solved my problem.
- Right click on Visual studio (whichever version you use)
- Properties
- Select compatibility tab
- Fill the checkbox which says "Run this program as administrator"
- Open the project from the file location
- Run the application
The accepted answer does not work in the latest version of windows. My Windows 10 operating system with VS 2017 did not have a "Compatibility Tab" in the properties window - it appears they have now moved this option.
For windows 10 users, follow the below steps:
Firstly, you need to be logged in as an administrator for the computer you're using.
- Right click Visual Studio (whichever version).
- Click "properties" - and a properties window will open.
- Click on the "Shortcut" tab.
- Click on "Advanced" box - at the bottom right.
- Check the "Run as Administrator" box, and click OK.
- Click "Apply" and then "OK" on the Visual Studio Properties window.
For previous versions, please follow the following steps
- Right click Visual Studio (whichever version).
- Click "properties" - and a properties window will open.
- Click on the "Compatibility" tab.
- Check the "Run as Administrator" box.
- Click "Apply" and then "OK" on the Visual Studio Properties window.
Your project should now open up as administrator going forwards, and common access issues to the Assembly will be resolved.
I was surprised when I can't find options always run as administrator for file of vs 2017 pro (devenv.exe). It was resolved and set only with troubleshoot compatibility option.
Solution for the latest window versions:
- Find "devenv.exe" file
- Right mouse click and selects "troubleshoot compatibility" option
- Troubleshoot program option
- Checks "The program requires additional permissions"
- Next
- Test the program
- Next
- Yes,save these settings for this program