Repro metabase COM Exceptions

Our project uses IIS to host custom web applications. We received an issue: when creating a web application some COM Exception is logged.

To reproduce the issue we created a console application that connects to IIS metabase. The Find method was the source for the COM Exception, so we tried some scenario’s and logged the outcome. See the listing below.

var directory = new System.DirectoryServices.DirectoryEntry(
try {
    var child = directory.Children.Find("Root", "IISWebVirtualDir");
    Console.WriteLine("Found directory {0}", child.Name);
catch(System.IO.DirectoryNotFoundException) {
    // child is not found (even when schemaclassname is wrong)
    Console.WriteLine("Directory not found");
catch(System.Runtime.InteropServices.COMException ex) {
    // 0x80070003: system cannot find the path (use connection 
    //             IIS://localhost/W3SVC/13)
    // 0x80070005: access denied (run without Administrative right)
    // 0x800706BE: metabase corrupt (edit applicationhost.config)
    // 0x80005000: unknown error (use iis:// instead of IIS://  
    //             or add / at end of connectionstring)
    // 0x80005008: Find with IIsWebDirectory as schemaclassname 
    //             (wrong argument) and item is present
    Console.WriteLine("COM Exception {0}: {1}", 
            ex.ErrorCode.ToString("X"), ex.ToString());
catch(Exception ex) {
    Console.WriteLine("Something is wrong: {0}", ex.Message);

Together with our metabase corruption repro we get a list of errorcodes. This list goes into our Knowledge Base with an advised next step.

Image courtesy of ratch0013 /
Image courtesy of ratch0013 /

About erictummers

Working in a DevOps team is the best thing that happened to me. I like challenges and sharing the solutions with others. On my blog I’ll mostly post about my work, but expect an occasional home project, productivity tip and tooling review.
This entry was posted in Development and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.