applicationHost.config错误:由于IIS共享配置权限不足,无法写入配置文件
我使用Microsoft.Web.Administration.ServerManager
类来管理Windows服务中的网站。applicationHost.config错误:由于IIS共享配置权限不足,无法写入配置文件
我使用模拟在我的代码,以管理员用户,用户有权修改权我applicationHost.config
,但我总是得到以下错误,当我做了.CommitChanges();
。
有一个我的代码的例子。
using (ServerManager svr = ServerManager.OpenRemote(args.IISName))
{
Site currentSite = svr.Sites.Where(item => item.Id == args.WebSite.Id).FirstOrDefault();
currentSite.Applications[0].VirtualDirectories[0].PhysicalPath = args.WebSite.PhysicalPath;
svr.CommitChanges();
}
我发现this solutions,但我的DCOM属性对象是锁定
Unhandled exception has occured in your application. If you click Continue, the application will ignore this error and attempt to continue. If you click Quit, the application will close immediately. FileName \?\UNC[MY PATH]\applicationHost.config Error: Cannot write configuration file due to insufficient permissions
我的设置是Windows 2008 R2上,IIS 7.5,框架3.5和我的applicationHost.config是一个SAN
我可以尝试什么?
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.UnauthorizedAccessException: Filename: \\?\[MY PATH]\applicationHost.config
Error: Cannot write configuration file due to insufficient permissions
at Microsoft.Web.Administration.Interop.IAppHostWritableAdminManager.CommitChanges()
at Microsoft.Web.Administration.ConfigurationManager.CommitChanges()
at Microsoft.Web.Administration.ServerManager.CommitChanges()
at Nms.IIS.Business.Manager.IISManager70.UpdateWebSiteEntity(UpdateWebSiteEntityArgs args)
at Nms.IIS.Business.Service.IISService70.UpdateWebSiteEntity(UpdateWebSiteEntityArgs args)
at IISSwitcher.Form1.btnProccess_Click(Object sender, EventArgs e) in C:\Form1.cs:line 70
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.4952 (win7RTMGDR.050727-4900)
CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
IISSwitcher
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file://[mypatch]/Altitude3%20Transfert/IISDirectorySwitch/IISSwitcher.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
Nms.IIS.Business
Assembly Version: 1.0.295.8874
Win32 Version: 1.0.295.8874
CodeBase: file://[mypatch]/Altitude3%20Transfert/IISDirectorySwitch/Nms.IIS.Business.DLL
----------------------------------------
Nms.Core
Assembly Version: 1.0.1954.8874
Win32 Version: 1.0.1954.8874
CodeBase: file://[mypatch]/Altitude3%20Transfert/IISDirectorySwitch/Nms.Core.DLL
----------------------------------------
System.Configuration
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
Microsoft.Practices.Unity
Assembly Version: 1.2.0.0
Win32 Version: 1.2.0.0
CodeBase: file://[mypatch]/Altitude3%20Transfert/IISDirectorySwitch/Microsoft.Practices.Unity.DLL
----------------------------------------
Microsoft.Practices.Unity.Interception
Assembly Version: 1.2.0.0
Win32 Version: 1.2.0.0
CodeBase: file://Microsoft.Practices.Unity.Interception.DLL
----------------------------------------
Microsoft.Practices.ObjectBuilder2
Assembly Version: 2.2.0.0
Win32 Version: 2.2.0.0
CodeBase: file://Microsoft.Practices.ObjectBuilder2.DLL
----------------------------------------
System.Core
Assembly Version: 3.5.0.0
Win32 Version: 3.5.30729.4926 built by: NetFXw7
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Core/3.5.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
Nms.Core.resources
Assembly Version: 1.0.1954.8874
Win32 Version: 1.0.1954.8874
CodeBase: file://Nms.Core.resources.DLL
----------------------------------------
Unity_ILEmit_InterfaceProxies
Assembly Version: 0.0.0.0
Win32 Version: 1.2.0.0
CodeBase: file://Microsoft.Practices.Unity.Interception.dll
----------------------------------------
Microsoft.Web.Administration
Assembly Version: 7.0.0.0
Win32 Version: 6.1.7600.16385
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.Web.Administration/7.0.0.0__31bf3856ad364e35/Microsoft.Web.Administration.dll
----------------------------------------
System.Runtime.Serialization
Assembly Version: 3.0.0.0
Win32 Version: 3.0.4506.4926 (NetFXw7.030729-4900)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Runtime.Serialization/3.0.0.0__b77a5c561934e089/System.Runtime.Serialization.dll
----------------------------------------
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
要解锁你的dcom属性对象,你只需要2个步骤来执行。
第1步 - 在 'Ahadmin.dll' 授予您 '完全控制':
- 转到您的IIS服务器和浏览到文件夹 'C:\ WINDOWS \ SYSTEM32 \'
- 查找“Ahadmin .dll文件“就可以了,然后右键单击打开属性框
- 转到‘安全’选项卡,并授予你的NT用户‘’如果你不能够授予您
- ‘完全控制完全控制’,转到这个”所有者'标签 并添加您的NT用户或您所属的管理员组,然后点击'应用' 而不是回到“安全”选项卡向您授予“完全控制”
第2步 - 授予你“完全控制”的注册表项:
- 在IIS服务器上打开“注册表编辑器“(运行命令:regedit)。
- 将光标放在左窗格的根目录下。
- 打开查找框并键入'ahadmin',然后单击查找。
- 注册表将在右窗格中找到一个键。右键点击此键的父 文件夹,打开属性框
- 转到“安全”选项卡,如果你不能够授予您“完全控制”授予您NT用户“完全控制”
-
,转到“所有者”选项卡 并添加您的NT用户或管理员组,然后单击“应用” 然后返回“安全”选项卡授予您“完全控制”
您现在可以编辑您的dcom属性对象
如果dcom porperties对象仍然锁定,请等待几分钟,然后尝试使用agai ñ。
之后,你只需要按照程序here。
确保两个文件的安全设置和份额的安全设置允许扮演用户修改文件。由于您正在使用UNC路径访问配置文件,因此您需要两个级别的权限。
如果虚拟目录映射到共享文件夹。 所有人(读取):windows下看共享的权限,默认7/W2K8股与创建。 更改共享的权限: 每个人(FullControl)
这使得IIS做什么它需要通过份额,因为它没有使用完整物理路径。
在我们的情况下,服务器磁盘已满。我们添加了附加磁盘空间,问题解决了。
确保项目文件夹未加密。 Visual Studio在使用加密文件夹时遇到问题。
我有我的用户文件夹加密和项目将无法打开,直到我将这些文件夹标记为未加密。这是一个愚蠢的VS不提供一个有意义的错误,说明你应该从项目文件夹中删除加密。
要删除加密权利,请右键单击项目文件夹,然后选择高级,然后取消选中加密复选框。将更改应用于文件夹本身以及所有嵌套的文件夹和文件。
我已经删除了我的解决方案现有的ApplicationHost.config文件,并重新装入的解决方案。解决方案本身创建了新的ApplicationHost.config文件。
它解决了我的问题。
沿着这些方向,检查文件的有效权限(类似于右键单击,属性,安全性,高级权限和有效权限)。这应该给你一个什么样的用户可以在文件系统级(NTFS)做了权威的排行榜。 – 2011-02-17 22:34:25
Everyting是正确的,但还是不行 – 2011-02-21 19:28:09