VSAddin issue on Windows Server 2003 (or XP)

Nov 23, 2009 at 4:55 PM

Just thought I'd share this tidbit since no googling around resulted in a solution:

WSPBuilderExtensions.msi distributes Microsoft.Web.Administration.dll that only functions on machines with IIS7 or later. This is generally not a big problem unless trying to get WCF services to run within IIS 6.  The ServiceModelReg.exe program that adds the .svc extensions and scriptmaps to IIS 6 blows up and bombs. The problem stems from the fact that the VSAddin project has a reference to this assembly and includes it in the setup project. When executing ServiceModelReg.exe, if the attempt to load the Microsoft.Web.Administration.dll assembly succeeds then it assumes the machine is running IIS7, not IIS6 causing it to blow up. The error that shows up in the Windows Application Event log is:

Event Type: Error
Event Source: System.ServiceModel.Install
Event Category: None
Event ID: 0
Date:  11/20/2009
Time:  3:38:19 PM
User:  N/A
System.TypeInitializationException: The type initializer for 'System.ServiceModel.Install.IisHelper' threw an exception. ---> System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {2B72133B-3F5B-4602-8952-803546CE3344} failed due to the following error: 80040154.
   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.ConfigurationManager.GetApplicationHostConfiguration()
   at Microsoft.Web.Administration.ServerManager.GetApplicationHostConfiguration()
   at System.ServiceModel.Install.Configuration.IIS7ConfigurationLoader.get_ApplicationHostConfiguration()
   at System.ServiceModel.Install.Configuration.IIS7ConfigurationLoader.CheckApplicationHostInstalled()
   at System.ServiceModel.Install.IisHelper..cctor()
   --- End of inner exception stack trace ---
   at Microsoft.Tools.ServiceModel.CommandArguments..ctor(String[] args)
   at Microsoft.Tools.ServiceModel.ServiceModelReg.Run(String[] args)
   at Microsoft.Tools.ServiceModel.ServiceModelReg.TryRun(String[] args)

Once I uninstalled WSPBuilder, I was able to run the WCF config utility properly.