applicationHost.config 错误:由于 IIS 共享配置权限不足,无法写入配置文件
我使用 Microsoft.Web.Administration.ServerManager 类来管理 Windows 服务中的网站。
我在代码中使用模拟,对于管理员用户,用户有权修改我的 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();
}
我找到这个解决方案,但是我的 dcom属性对象是锁
发生了未处理的异常 您的申请。如果您点击 继续,应用程序将忽略 出现此错误并尝试继续。如果 您单击“退出”,应用程序将 立即关闭。文件名 \?\UNC[我的 路径]\applicationHost.config 错误: 无法写入配置文件,因为 权限不足
我的设置是 Windows 2008 R2、IIS 7.5、framework 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.
I use the Microsoft.Web.Administration.ServerManager
class to manage a web site in a windows service.
I use impersonation in my code, with an admin user, the user has the right to modify my applicationHost.config
but I always get the following error when I do a .CommitChanges();
.
There is an example of my code.
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();
}
I find this solutions, but my dcom properties object is lock
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
My setup is Windows 2008 R2, IIS 7.5, framework 3.5 and my applicationHost.config is on a SAN
What could I try ?
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
在我们的例子中,服务器磁盘已满。我们添加了额外的磁盘空间,问题就解决了。
In our case the server disk was full. We added addtional disk space and the problem is solved.
我已从解决方案中删除现有的 applicationhost.config 文件并再次重新加载解决方案。解决方案本身创建了新的 ApplicationHost.config 文件。
它解决了我的问题。
I have deleted existing applicationhost.config file from my solution and reloaded the solution again. Solution created new ApplicationHost.config file itself.
Its resolved my issue.
要解锁 dcom 属性对象,您只需执行 2 个步骤。
步骤 1 - 授予您对“Ahadmin.dll”的“完全控制权”:
添加您的 NT 用户或您所属的管理组,然后单击“应用”
然后返回“安全”选项卡以授予您“完全控制”
步骤 2 - 授予您对注册表项的“完全控制”:
该密钥的文件夹并打开属性框
如果您无法授予您“完全控制”,请转到“所有者”选项卡
添加您的 NT 用户或您所属的管理员组,然后单击“应用”
然后返回“安全”选项卡以授予您“完全控制”
您现在可以编辑 dcom 属性对象
如果 dcom 属性对象仍然处于锁定状态,请等待几分钟,然后重试。
之后,您只需按照以下过程操作此处。
To unlock your dcom properties object, you just have 2 steps to perfom.
Step 1 - Grant you 'Full Control' on the 'Ahadmin.dll' :
and add your NT user or an admin group that you're member and click 'Apply'
And than return to the 'Security' tab to grant you 'Full control'
Step 2 - Grant you 'Full Control' on the registry key :
folder of this key and open properties box
If you're not able to grant you 'Full control', goto the 'Owner' tab
and add your NT user or an admin group that you're member and click 'Apply'
And than return to the 'Security' tab to grant you 'Full control'
You can now edit your dcom properties object
If the dcom porperties object is still lock, just wait some minutes and try again.
After that, you just have to follow the procedure here.
确保包含项目的文件夹未加密。 Visual Studio 在处理加密文件夹时遇到问题。
我的用户文件夹已加密,并且在将这些文件夹标记为未加密之前,项目将无法打开。 VS 没有提供有意义的错误来表明您应该从项目文件夹中删除加密,这很愚蠢。
要删除加密,请右键单击项目文件夹,然后单击“高级”,然后取消选中“加密”复选框。将更改应用到文件夹本身以及所有嵌套的文件夹和文件。
Ensure that the folder with the project is NOT encrypted. Visual Studio has problems working with encrypted folders.
I have my user folder encrypted and projects won't open until I mark these folders as non-encrypted. It's a silly that VS doesn't provide a meaningful error stating that you should remove encryption from the project folder.
To remove the encryption right click the project folder, then Advanced, then unselect the Encrypt checkbox. Apply the changes to the folder itself and all nested folders and files.
确保文件的安全设置和共享的安全设置都允许模拟用户修改文件。由于您使用 UNC 路径访问配置文件,因此您需要两个级别的权限。
Ensure that both the file's security settings and the share's security settings allow the impersonating user to modify the file. Since you're accessing the config file with a UNC path, you need permissions at both levels.
如果虚拟目录映射到共享文件夹。查看共享的权限,默认情况下在 windows 7/w2k8 下创建共享时使用:
大家(读)。
将共享的权限更改为:
每个人(完全控制)
这允许 IIS 通过共享执行其需要的操作,因为它不使用完整的物理路径。
If the virtual directory is mapped to a shared folder. Look at the permissions of the share, by default under windows 7/w2k8 shares are created with:
Everyone (Read).
Changing the permissions of the share to:
Everyone (FullControl)
This allows IIS to do what it needs through the share, as it is not using the full physical path.