Microsoft.Web.Administration: System.UnauthorizedAccessException

徘徊边缘 提交于 2020-01-04 14:09:13

问题


I use the Windows.Web.Administration dll in a C# program to manage IIS 7 (I use only the method Recycle).

The first problem was:

System.UnauthorizedAccessException: Filename: redirection.config
Error: Cannot read configuration file due to insufficient permissions

And later I have added NETWORK SERVICE with full control at the folder C:\Windows\System32\inetsrv".

Now I have this message error:

System.UnauthorizedAccessException: Access is denied. (Exception from
HRESULT: 0x80070005 (E_ACCESSDENIED))
at Microsoft.Web.Administration.Interop.IAppHostProperty.get_Value()
at Microsoft.Web.Administration.ConfigurationElement.GetPropertyValue(IAppHostProperty property)
at Microsoft.Web.Administration.ConfigurationElement.GetAttributeValue(String attributeName)
at Microsoft.Web.Administration.ApplicationPool.get_State()

How can I avoid this?


回答1:


Run your program as administrator, or if you are in VS run VS as administrator.

MWA requires administrator permissions to talk to IIS interfaces.



来源:https://stackoverflow.com/questions/29645830/microsoft-web-administration-system-unauthorizedaccessexception

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!