无法加载文件或程序集'System.Web'或其某个依赖项。拒绝访问。

3
我运行一个.NET Web应用程序时,遇到了一个未知的EventLog错误。
该应用程序主要从数据库读取数据,然后从磁盘读取文件大小并将其写回到数据库中。
我已经在我的工作站(IISExpress)和我们的另一台服务器(安装有IIS7的Windows 2008)上成功地运行了该应用程序,没有任何问题。
但是当我在我们的2003 R2服务器上运行它时,使用IIS6时,出现了一些奇怪的行为。IIS应用程序启动并报告没有任何问题,但是当我尝试访问网页时,会出现“服务器应用程序不可用”的提示,并且服务器的EventLog给出以下信息:
Event Type: Error
Event Source:   ASP.NET 4.0.30319.0
Event Category: None
Event ID:   1325
Date:       24.05.2011
Time:       13:29:11
User:       N/A
Description:
Failed to initialize the AppDomain:/LM/W3SVC/1309226359/Root

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 is denied.

StackTrace:    at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Activator.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(String assemblyName, String typeName)
at System.AppDomain.CreateInstance(String assemblyName, String typeName)
at System.AppDomain.InternalCreateInstanceWithNoSecurity(String assemblyName, String typeName)
at System.AppDomain.InternalCreateInstanceWithNoSecurity(String assemblyName, String typeName)
at System.Activator.CreateInstance(AppDomain domain, String assemblyName, String typeName)
at System.Web.Hosting.ApplicationManager.CreateAppDomainWithHostingEnvironment(String appId, IApplicationHost appHost, HostingEnvironmentParameters hostingParameters)
at System.Web.Hosting.ApplicationManager.CreateAppDomainWithHostingEnvironmentAndReportErrors(String appId, IApplicationHost appHost, HostingEnvironmentParameters hostingParameters)

这个应用程序在IIS中继续运行。这个IIS还托管了许多其他站点而没有任何问题。是的,该应用程序设置为在.NET 4上运行,并且服务器也托管了其他没有任何问题的.NET 4应用程序。

据我所知,它无法加载System.Web程序集,但我不确定这甚至是如何可能的...

以下是应用程序的web.config:

<?xml version="1.0"?>
<configuration>
    <system.web>
        <globalization culture="nb-NO"/>
        <compilation debug="true" targetFramework="4.0">
            <assemblies>
                <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            </assemblies>
            </compilation>
        <customErrors mode="Off"></customErrors>
        <xhtmlConformance mode="Strict"/>
        <httpRuntime requestValidationMode="2.0"/>
    </system.web>
    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"></modules>
    </system.webServer>
</configuration>
2个回答

2

这可能是由于您的Web应用程序文件夹中的文件系统权限不足所致。

我通过为Web根目录及其所有子文件授予ASPNETNetwork Service帐户的读取和执行以及列出文件夹内容权限来解决了相同的问题。


0

Lachlan Roche的回答对我有用。具体来说,我将我的Web应用程序文件夹授予LOCAL_MACHINE \ Users和LOCAL_MACHINE \ IIS_IUSRS的完全控制权限,其中LOCAL_MACHINE是我的本地计算机域。我没有检查这两个组是否都需要完全访问权限,因此您可能不需要同时授予访问权限。

我的系统是Windows 7 Enterprise,带有IIS 7.5.7600.16385和Visual Studio 12


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接