简体   繁体   中英

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

Seems like there are already 100s of questions like these.. I have search through quite many of them and they don't seem to suggest anything that I haven't tried yet.

I get the error:

Could not load file or assembly 'System.Web, Version=4.0.0.0, Culture=neutral,    PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Access is denied. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

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

Source Error: 



Line 44:         private static IKernel CreateKernel()
Line 45:         {
Line 46:             var kernel = new StandardKernel();
Line 47:             try
Line 48:             { 

The above code is present in my Ninject Initializer.

I have given " Everyone " Permissions on:

C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319

C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319

C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\ .NETFramework

FusionLog Details:

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\Program Files (x86)\IIS Express\iisexpress.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: DisplayName = System.Web, Version=4.0.0.0, Culture=neutral,    PublicKeyToken=b03f5f7f11d50a3a
(Fully-specified)
LOG: Appbase = file:///F:/TFS/MMSChange/Main/SMRH.MMSChange/SMRH.MMSChange.Web/
LOG: Initial PrivatePath = F:\TFS\MMSChange\Main\SMRH.MMSChange\SMRH.MMSChange.Web\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Found application configuration file     (F:\TFS\MMSChange\Main\SMRH.MMSChange\SMRH.MMSChange.Web\web.config).

I have also given everyone permissions on my code's folders. I have tried running ProcMon (which has helped me with the similar problems for different solutions before); but it does not create a single entry for system.web.dll.

I have impersonation built in. I use separate accounts to access the database and that impersonation for the database account breaks this. Without impersonation the app runs fine. (But has no data because all the db calls fail)

Funny thing is though, if I deploy the same code to my local machine and run it via an IIS Web Site: it works. But if I just debug it from my IDE it fails.

Alright, so I found the solution.

After many hours of debugging and contacting Microsoft support, which yielded nothing. I decided to start from scratch. I got another instance of ProcMon running and filtered results to show only IISExpress results (Since this is the one which is giving me error).

Then I compiled and launched my application from the IDE and waited for the error to come. After I got the error, I filtered the results by " Access Denied ".

Usually I filtered the results to look for system.web.dll, but this time i decided to ignore it.

I found that the only file which was throwing access denied was: " C:\\Users\\1roj1\\Documents\\IISExpress\\config\\aspnet.config " (Where 1roj1 is my user account).

I gave my impersonate user full access to this file and voila everything worked!

I think you need to register .net Freamework 4.0 for IIS for the above issue. Here are the steps..

  1. Open Command prompt as Administrator
  2. Navigate to " C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319 " directory in command prompt [use the command cd C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319 ]
  3. Register .net FrameWork for IIS [use command aspnet_regiis.exe -i ]
  4. Restart IIS [use command iisreset ].
  5. Done.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

Related Question Could not load file or assembly 'System, Version=4.0.0.0, Culture=neutral' or one of its dependencies Could not load file or assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=561934e089' or one of its dependencies Could not load file or assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies Could not load file or assembly 'Npgsql, Version=4.0.5.0,culture=neutral…' or one of its dependencies. Only occurs in Task Scheduler Could not load file or assembly 'System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies Could not load file or assembly 'System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies Could not load file or assembly 'System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies Could not load file or assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies Could not load file or assembly 'System.IO, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies Could not load file or assembly 'Microsoft.SqlServer.Types, Version=12.0.0.0, Culture=neutral, PublicKeyToken=myKey' or one of its dependencies.
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM