I'm working on an application that will allow my team to deploy new sites to all of our IIS7 servers from a remote ClickOnce application using MWA.
If I run the application from the target server (let's say SERVER01), it works. I'm able to create my AD account for the application pool ID, create the app pool, set the ID, create the site, and add the site to the app pool. Here's the code for the part that is failing:
ServerManager IISAdmin = ServerManager.OpenRemote(ServerName);
ApplicationPool appPool = IISAdmin.ApplicationPools.Add(ApplicationName);
The first line works. It will connect to the remote server. When I attempt to add the new application pool, I get an exception that looks like this:
Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Web.Administration.Interop.IAppHostWritableAdminManager'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{FA7660F6-7B3F-4237-A8BF-ED0AD0DCBBD9}' failed due to the following error: Interface not registered (Exception from HRESULT: 0x80040155). at Microsoft.Web.Administration.ConfigurationManager.CreateWritableAdminManager(WebConfigurationMap webConfigMap, String configPathToEdit, Boolean isAdminConfig) at Microsoft.Web.Administration.ConfigurationManager.CreateConfiguration(WebConfigurationMap configMap, String configPathToEdit, Boolean isAdminConfig) at Microsoft.Web.Administration.ConfigurationManager.GetConfiguration(String rawConfigurationPath, String cacheKey, Boolean isAdminConfig) at Microsoft.Web.Administration.ServerManager.get_ApplicationPoolsSection() at Microsoft.Web.Administration.ServerManager.get_ApplicationPools() at Rock.QL.WET.PushApp.IISConfig.ConfigureSite.CreateAppPool(String ServerName, String ApplicationName, String ServiceAccountName, String Password, String Domain)
It works locally, but not remotely. SERVER01 is on Server 2008, DESKTOP01 is on Vista SP1. I'm running the application as an account that has admin rights on the remote server.
I've been fighting with this for quite some time, so any help would be greatly appreciated.