Couldnotloadfileorassembly'AjaxControlToolkit'oroneofitsdependencies.拒绝访问。

作者:佚名 来源:本站原创 点击数: 发布时间:2009年06月03日

问题:打开网站提示“Could not load file or assembly 'AjaxControlToolkit' or one of its dependencies. 拒绝访问。 ”

 

Server Error in '/' Application.

Could not load file or assembly 'AjaxControlToolkit' or one of its dependencies. 拒绝访问。

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 'AjaxControlToolkit' or one of its dependencies. 拒绝访问。

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Assembly Load Trace: The following information can be helpful to determine why the assembly 'AjaxControlToolkit' could not be loaded.

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLMSoftwareMicrosoftFusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLMSoftwareMicrosoftFusion!EnableLog].

Stack Trace:

[FileLoadException: Could not load file or assembly 'AjaxControlToolkit' or one of its dependencies. 拒绝访问。]

[FileLoadException: Could not load file or assembly 'AjaxControlToolkit, Version=1.0.10301.0, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e' or one of its dependencies. 拒绝访问。]
   System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0
   System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +43
   System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +127
   System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +142
   System.Reflection.Assembly.Load(String assemblyString) +28
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +46

[ConfigurationErrorsException: Could not load file or assembly 'AjaxControlToolkit, Version=1.0.10301.0, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e' or one of its dependencies. 拒绝访问。]
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +613
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +203
   System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +105
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +178
   System.Web.Compilation.BuildProvidersCompiler..ctor(VirtualPath configPath, Boolean supportLocalization, String outputAssemblyName) +54
   System.Web.Compilation.ApplicationBuildProvider.GetGlobalAsaxBuildResult(Boolean isPrecompiledApp) +227
   System.Web.Compilation.BuildManager.CompileGlobalAsax() +52
   System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +337

[HttpException (0x80004005): Could not load file or assembly 'AjaxControlToolkit, Version=1.0.10301.0, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e' or one of its dependencies. 拒绝访问。]
   System.Web.Compilation.BuildManager.ReportTopLevelCompilationException() +58
   System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +512
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters) +729

[HttpException (0x80004005): Could not load file or assembly 'AjaxControlToolkit, Version=1.0.10301.0, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e' or one of its dependencies. 拒绝访问。]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +8886319
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +85
   System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +259


Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053

 

解决问题思路:出现“拒绝访问”这样的提示,一般都是权限的问题导致的。既然错误提示到了“AjaxControlToolkit”文件,那我们就找到BIN目录的“AjaxControlToolkit.DLL”文件,和其他版本的文件对比下,对比后和其他版本的文件完全一致,所以我们排除了不是DLL文件的问题。到底是什么阻止了访问呢,我们再看安装的目录权限是否正确,检查后,具有 NETWORK SERVIC、IIS用户权限正确。服务器装的是麦咖啡(McAfee)杀毒软件,因为麦咖啡有访问保护功能,所以想到了这一点,会不会是麦咖啡问题。打开麦咖啡日志一看,结果看到这样一条提示:

2009-6-3 8:48:06 1092 NT AUTHORITYNETWORK  ERVICE 

c:windowssystem32inetsrvw3wp.exe 

C:WINDOWSMicrosoft.NETFrameworkv2.0.50727Temporary ASP.NET Filesroot2609d9da94491186assemblytmpNSX436UVAjaxControlToolkit.DLL 

通用最大保护:禁止在 Windows 文件夹中创建新的可执行文件 

从上面提示我们可以看出,麦咖啡阻止了执行,知道了问题所在了,我们就好解决了。

 

解决方法:打开麦咖啡软件,找到“访问保护”--“通用最大保护”--“禁止在 Windows 文件夹中创建新的可执行文件”,这条规则设置为不阻止即可。

如下图: