似乎已经有100多个这样的问题。.我已经搜索了很多问题,它们似乎并没有建议我没有尝试过的任何问题。

我得到了错误:

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:             {

上面的代码存在于我的Ninject初始化程序中。

我给了“每个人”权限:

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

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

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

FusionLog详细信息:
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).

我还向所有人授予了我的代码文件夹的权限。我曾经尝试过运行ProcMon(以前曾帮助我解决过不同解决方案的类似问题);但是它不会为system.web.dll创建单个条目。

我内置了模拟功能。我使用单独的帐户来访问数据库,并且该数据库帐户的模拟功能可以解决此问题。在没有模拟的情况下,该应用可以正常运行。 (但是没有数据,因为所有数据库调用都失败了)

但是,有趣的是,如果我将相同的代码部署到本地计算机上并通过IIS网站运行它,那么它将起作用。但是,如果我只是从IDE中调试它,它将失败。

最佳答案

好了,所以我找到了解决方案。

经过许多小时的调试并与Microsoft支持人员联系,结果一无所获。我决定从头开始。我得到了另一个 ProcMon 实例,该实例正在运行并筛选结果以仅显示IISExpress结果(因为这是给我错误的结果)。

然后,我从IDE编译并启动了我的应用程序,并等待错误发生。收到错误后,我按“访问被拒绝”过滤了结果。

通常我会过滤结果以查找system.web.dll,但是这次我决定忽略它。

我发现唯一拒绝访问的文件是:“ C:\Users\1roj1\Documents\IISExpress\config\aspnet.config ”(其中1roj1是我的用户帐户)。

我给我的模拟用户完全访问此文件的权限,瞧,一切正常!

10-02 01:46
查看更多