为什么使用IIS7.5的Microsoft.Web.Management.dll只能在64位处理工作? [英] Why does using IIS7.5's Microsoft.Web.Management.dll only work in a 64bit process?
问题描述
我在写一些code,允许用户远程管理IIS7。引擎盖下的这增加了授权规则 C:\ WINDOWS \ SYSTEM32 \ INETSRV \设置\ administration.config
在以下配置部分:
I'm writing some code to permit users to remotely manage IIS7. Under the bonnet this adds authorisation rules to c:\windows\system32\inetsrv\config\administration.config
under the following config section:
system.webServer /管理/授权/ authorizationRules
我使用了 Microsoft.Web.Administration
集和命名空间与code类似以下内容:
I'm using the Microsoft.Web.Administration
assembly and namespace with code similar to the following:
using Microsoft.Web.Management.Server;
...
ManagementAuthorization.Grant("MySiteUser, "My Web Site", false);
它运行良好此code将引发运行在32位的过程中,如果建成的64位异常:
This code throws an exception if run in a 32 bit process, if built as 64 bit it runs fine:
System.Runtime.InteropServices.COMException was unhandled
Message=Filename: \\?\C:\Windows\system32\inetsrv\config\administration.config
Error: The configuration section 'system.webServer/management/authorization' cannot be read because it is missing a section declaration`
然而其他的服务器管理任务,使用 Microsoft.Web.Administration
集和命名空间的工作就好在32位进程,例如执行的:
However other server management tasks performed using the Microsoft.Web.Administration
assembly and namespace work just fine in a 32 bit process, for example:
using Microsoft.Web.Administration;
....
int iisNumber = 60000;
using (ServerManager serverManager = new ServerManager())
{
var site = serverManager.Sites.Where(s => s.Id == iisNumber).SingleOrDefault();
if (site != null)
{
site.Stop();
}
}
这两个组件出现在海关总署,是纯MSIL(即使有一个COM互操作层直接跟IIS7的底层管理机制)。
Both these assemblies appear in the GAC and are pure MSIL (even though there is a COM interop layer to talk directly to IIS7's underlying management mechanisms).
底层配置文件的applicationHost.config
和 administration.config
只看到64位编辑器(如记事本.exe或NotePad2.exe),我怀疑这就是为什么我的code不能修改 administration.config
通过 Microsoft.Web 。管理
The underlying configuration files applicationHost.config
and administration.config
are only visible to 64 bit editors (e.g. notepad.exe or NotePad2.exe) and I suspect that this is why my code can't modify administration.config
via the Microsoft.Web.Management
为何 Microsoft.Web.Administration
让我读/修改的applicationHost.config
在32位过程,但是 Microsoft.Web.Management
只能读取/修改 administration.config
如果在64位进程中运行?
Why does the Microsoft.Web.Administration
allow me to read/modify applicationHost.config
in a 32 bit process but Microsoft.Web.Management
can only read/modify administration.config
if run in a 64 bit process?
我无法重新编译我的项目目标64,因为有对我们没有源代码的32位COM库的依赖性。我可以建立一个工作围绕这将涉及拨打电话到进程外的64位应用程序的WCF(或一些这样类似的事情),但将preFER没有。
I am unable to recompile my project to target x64 because there is a dependency on a 32bit COM library that we don't have source for. I can build a work around which would involve making calls to an out of process 64 bit WCF app (or some such similar thing) but would prefer not to.
推荐答案
经过一番挖掘它看起来这是一个错误:
After some digging it looks like this is a bug:
本论坛帖子和后由卡洛斯·阿吉拉尔解释了所有:
This forum thread and a post by Carlos Aguilar explains all:
http://forums.iis.net/p/1157779/1956471.aspx
现在我明白了这个问题,是什么 发生的是,卡西尼号是一个32位 在一个联合进程, 在我们的配置错误让我们尝试 加载重定向SYSWOW (代替SYSTEM32),这是 我们之所以不能找到 administration.config。运行在64 位过程中减轻了问题 原因有没有神奇重定向 我们去正确的文件夹。
Now I understand the issue, what is happening is that Cassini is a 32 bit process and that in conjunction of a bug in our configuration makes us try to load the "redirected" syswow (instead of system32) which is the reason why we cannot find administration.config. Running in 64 bit process alleviates the problem cause there is no "magic" redirection and we go to the right folder.
任何32位进程将会遇到这种roadhump。
Any 32 bit process is going to encounter this roadhump.
这篇关于为什么使用IIS7.5的Microsoft.Web.Management.dll只能在64位处理工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!