Fedor Hajdu
Fedor Hajdu

Reputation: 4695

COM exception when using ServerManager class from Microsoft.Web.Administration

I'm trying to retrieve a website from IIS with following code:

var serverManager = new ServerManager();

var site = serverManager.Sites.FirstOrDefault(s => s.Name == Config.WebSiteName);

ServerManager class is defined in Microsoft.Web.Administration, I'm using reference with copy local and the dll is deployed with the application.

If my app is ran on Win7 64bit it works correctly but when I try to run it on Windows XP 32 it throws an exception:

Retrieving the COM class factory for component with CLSID {2B72133B-3F5B-4602-8952-803546CE3344} failed due to the following error: 80040154

I'm deploying the app as stand alone winforms .net 3.5 application (built for Any CPU).

Any ideas?

Thanks in advance.

Upvotes: 2

Views: 2570

Answers (1)

Rup
Rup

Reputation: 34408

That error is REGDB_E_CLASSNOTREG, i.e. the code it's trying to call doesn't exist on your XP machine. From the docs

Provides read and write access to the IIS 7 configuration system.

Win XP Pro only has IIS 6 not 7. You'll have to use some other mechanism, e.g. iisweb.vbs, adplus or the COM objects they use behind the scenes.

Upvotes: 6

Related Questions