Got this funny little thing today when I was trying to enumerate children of a Directory Entry:.

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.ChildEnumerator..ctor(DirectoryEntry container)
   at System.DirectoryServices.DirectoryEntries.GetEnumerator()
   at Program.Program.Main(String[] args)

Very helpful error message : “Unknown error (0x80005000)”,  search on google didn’t turn up anything useful at first glance,  something about primary tokens in asp.net and something about this popping up when people were doing LDAP stuff..  neither helped me much.

The error was occuring when I defined my DirectoryEntry so after a short code review I found the issue. I was calling :

DirectoryEntry AppPoolRoot = new DirectoryEntry("IIS://Localhost/W3SVC/AppPools/");

When I should have been doing this.

DirectoryEntry AppPoolRoot = new DirectoryEntry("IIS://Localhost/W3SVC/AppPools");

Notice the trailing slash,  that little bugger was causing this error.  So make sure you are using the correct path if you run into this.

Tagged with:
 

2 Responses to Solving COMException / Unknown error (0x80005000)

  1. Anonymous says:

    Thank you :)

  2. Anonymous says:

    Thank you :). Saved me a headache.