Could not load file or assembly due to insufficient permission when setting up the website

Lionsure 2020-09-20 Original by the website

When setting up and deploying website, various errors often occur, and some errors are caused by insufficient permissions. Even though these errors are simple and unremarkable, they are often difficult to find because they are hidden.

Take IIS_W3C(IIS_IUSRS for IIS7) without permission to access the dll files in the bin directory. The website has been uploaded to the server. An error was found in the program when setting up the website. After modifing the wrong dll, upload it to the server and copy it to the bin directory. At this time, because IIS_W3C does not have permission to access the uploaded dll, it throws error. This error is very concealed. Originally, all dll files in the bin directory can be accessed by IIS_W3C. Who would have thought that dll files re-uploaded and copied past would cause errors due to insufficient permission.

 

1. IIS_W3C(IIS_IUSRS for IIS7) does not have the permission to access the dll file in the bin directory, and the following error will occur:

Exception: System.IO.FileLoadException

Message: Could not load file or assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Access denied.

Throwing an exception is a file loading exception, specifically that it cannot load System.Web or System.Web dependencies.

 

Sometimes the following error occurs at the same time:

Failed to execute request because the App-Domain could not be created. Error: 0x80070005 access denied.

It means: App-Domain cannot be created, so the execution request fails.

 

2. Solution

As long as IIS_W3C(or IIS_IUSRS) does not have permission to access dll files(usually newly uploaded dlls), assign to IIS_W3C read permission, the problem will be solved.

There is another situation, when opening an html or dynamic aspx page, it prompts no permission to visit, usually users who visit the website anonymously(user starting with IUSR_ by default) do not have the permission to read this page.