How to reference Microsoft.Web.Administration?

后端 未结 11 1660
你的背包
你的背包 2020-12-08 09:25

The Microsoft.Web.Administration assembly is found in C:\\Windows\\System32\\inetsrv on my machine. I believe it is installed as part of IIS. The assembly is al

11条回答
  •  余生分开走
    2020-12-08 09:47

    The following steps are working for me:

    1. Go to C:\Windows\System32\inetsrv and check if the file Microsoft.Web.Administration.dll exists. If you are missing the Microsoft.Web.Administration.dll in C:\Windows\System32\inetsrv, enable IIS Management Console in your Windows Features:

    Adding the management service to windows features

    1. In your Visual Studio project, add the reference to the Microsoft.Web.Administration.dll:
    2. Now your .proj-file has the following the entry: C:\Windows\System32\inetsrv\Microsoft.Web.Administration.dll. You could adapt this path to e.g. %windir%\System32\inetsrv\Microsoft.Web.Administration.dll to make it more robust.

    When you move the app to a different system, the app also references to the Microsoft.Web.Administration.dll on the target system. Because the Microsoft.Web.Administration.dll could be different between the windows systems it is not recommended to deliver a copy of this assembly file by the app. A copy could be incompatible with the IIS on the target system.

    It is also not recommended to reference a copy of the assembly on the same system, because perhaps the Microsoft.Web.Administrator.dll and the IIS will change due an Windows Update! Then your referenced copy of Microsoft.Web.Administrator.dll is incompatible with the updated IIS.

    When the Microsoft.Web.Administrator.dll is missing on the target system, then activate the Management Console as descibed in step 1 above. Alternatively you can use the cmd (open as Administrator) and activate the Windows Feature Management Console by DISM.exe via the following command:

    C:\Windows\System32\Dism.exe /enable-feature /online /featurename:IIS-ManagementConsole
    

    This command could be useful when you want to distribute your app via an setup.

提交回复
热议问题