Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
543 views
in Technique[技术] by (71.8m points)

c# - applicationHost.config错误:由于IIS共享配置的权限不足,无法写入配置文件(applicationHost.config Error: Cannot write configuration file due to insufficient permissions with IIS shared configuration)

I use the Microsoft.Web.Administration.ServerManager class to manage a web site in a windows service.

(我使用Microsoft.Web.Administration.ServerManager类来管理Windows服务中的网站。)

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();

(我在管理员代码中使用模拟功能,该用户有权修改我的applicationHost.config但是当我执行.CommitChanges();时,总是收到以下错误.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

(我找到了这个解决方案 ,但是我的dcom属性对象是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

(FileName \?\ UNC [MY PATH] \ applicationHost.config错误:由于权限不足,无法写入配置文件)

My setup is Windows 2008 R2, IIS 7.5, framework 3.5 and my applicationHost.config is on a SAN

(我的设置是Windows 2008 R2,IIS 7.5,框架3.5,而我的applicationHost.config位于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.
  ask by Cédric Boivin translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

In our case the server disk was full.

(在我们的例子中,服务器磁盘已满。)

We added addtional disk space and the problem is solved.

(我们添加了额外的磁盘空间,问题得以解决。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...