AppDomain 影子复制文件访问在 IIS6 上运行的 ASP.NET 站点被拒绝 [英] AppDomain shadow copied file access denied with ASP.NET site running on IIS6

查看:22
本文介绍了AppDomain 影子复制文件访问在 IIS6 上运行的 ASP.NET 站点被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在将 AppDomains 的卷影复制功能与在 IIS 下运行的 ASP.NET 网站结合使用时遇到了一些问题.问题是由于权限不足,IIS用户无法读取或执行影子复制文件.

I have some trouble with the shadow copy feature of AppDomains in combination with a ASP.NET website running under IIS. The problem is that the shadow copied files can not be read or executed by the IIS user because of insufficient permissions.

我在执行新的 AppDomain 中的代码时收到以下错误消息(通过 DoCallBack 的回调方法):
System.IO.FileLoadException:无法加载文件或程序集My.Namespace.AssemblyName,Version=0.0.3.2231,Culture=neutral,PublicKeyToken=null"或其依赖项之一.访问被拒绝.

I get the following error message when the code in the new AppDomain is executed (through a callback method via DoCallBack):
System.IO.FileLoadException: Could not load file or assembly 'My.Namespace.AssemblyName, Version=0.0.3.2231, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Access is denied.

融合日志:

Assembly manager loaded from:  C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
Running under executable  c:\windows\system32\inetsrv\w3wp.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: User = NT AUTHORITY\NETWORK SERVICE
LOG: DisplayName = My.Namespace.AssemblyName, Version=0.0.3.2231, Culture=neutral, PublicKeyToken=null
 (Fully-specified)
LOG: Appbase = file:///C:/Inetpub/wwwroot/Web Suite/Widgets
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file: \\?\C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet.config
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Inetpub/wwwroot/Web Suite/Widgets/My.Namespace.AssemblyName.DLL.
ERR: Failed to complete setup of assembly (hr = 0x80070005). Probing terminated.

我已经做过的:
我已授予用户NETWORK SERVICE"的C:/Inetpub/wwwroot/Web Suite/Widgets"文件夹读取和执行权限.
当我关闭卷影复制功能时,一切正常.
即使在 Visual Studio 2008 下的本地计算机上,它也可以正常运行.
授予 Widgets 文件夹中的所有文件(而不是文件夹本身)读取和执行权限并不能解决问题.

What I have already done:
I have granted the 'C:/Inetpub/wwwroot/Web Suite/Widgets' folder read and execution permission for the user 'NETWORK SERVICE'.
When I turn off the shadow copying feature, everything goes fine.
Even on my local computer under Visual Studio 2008 it runs without any problem.
Granting all files (instead of the folder itself) in the Widgets folder read and execution permission does not solve the problem.

我认为这与 ASP.NET 临时文件文件夹的权限有关:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\web suite
这个文件夹,它的所有子文件夹和其中的文件都已经读过,读过&执行用户网络服务"的权限.所以这也不是问题.

I thought it have to do with the permissions on the ASP.NET temporary files folder:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\web suite
This folder, all its sub folders and the files within them have read and read & execute permissions for the user 'NETWORK SERVICE'. So that's not the problem either.

简而言之:
为什么我的站点(在 IIS6 下运行)无法访问新 AppDomain 的影子复制文件?

推荐答案

问题的原因是 CachePath 默认值.如果 AppPool 在网络服务下运行,则使用 DefaultUser 临时文件夹位置(我不知道为什么).但网络服务无权访问该文件夹,这是异常的原因.解决方案是显式设置 CachePath.比如我们可以使用ASP.NET AppPool缓存路径:

The reason of the problem is CachePath default value. If an AppPool is run under network service, DefaultUser temp folder location is used (I don't know why). But Network Service doesn't have access to the folder and it's the reason of the exception. The solution is to set CachePath explicitly. For example, we can use ASP.NET AppPool cache path:

var domainInfo = new AppDomainSetup
  {
    CachePath = AppDomain.CurrentDomain.SetupInformation.CachePath
    /* ...*/
  };

这篇关于AppDomain 影子复制文件访问在 IIS6 上运行的 ASP.NET 站点被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆