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( "IIS://localhost/W3SVC/1"); 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 / FreeDigitalPhotos.net