When using DirectoryServices to access "IIS://" Schema IIS6 Management compatibility pack needs to be installed (System.Runtime.InteropServices.COMException (0x80005000))

When you try to access IIS 7 metabase using System.DirectoryServices (or ADSI providers) you encounter the following error

System.Runtime.InteropServices.COMException (0x80005000): Unknown error (0x80005000)

at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)

at System.DirectoryServices.DirectoryEntry.Bind()

at System.DirectoryServices.DirectoryEntry.get_IsContainer()

at System.DirectoryServices.DirectoryEntries.CheckIsContainer()

at System.DirectoryServices.DirectoryEntries.Find(String name, String schemaClassName)


Sample Code Which is failing

DirectoryEntry iisServer;

iisServer = new DirectoryEntry(“IIS://IISSERVER/W3SVC/1”);

DirectoryEntry rootFolder = iisServer.Children.Find(“Root”, “IIsWebVirtualDir”);  <<= This is where exception is being thrown



Environment: IIS7, Windows 2008 64 bit


ADSI is not a preferred method to access IIS 7 metabase. For portability purposes , ADSI provider is still supported.

In order to execute the DirectoryServices code against “IIS://” namespace, you will need Compatibility pack installed on Windows 2008


IIS6 Management compatibility pack needs to be installed


Use IIS 7.0: WMI Provider http://msdn.microsoft.com/en-us/library/aa347459.aspx