Tuesday, April 25, 2006

No Such Interface (E_NOINTERFACE)

Last week, my COM server (C#, VS2005) stopped working. The client call to "CoCreateInstanceEx" started throwing a "No Such Interface" exception (E_NOINTERFACE) on a class that had always worked before. An old DLL (thanks Dan) still worked. Probably not coincidentally, the COM server also stopped working on Dan's machine.

I tried backing out some recent OS upgrades, without success. (It's possible that the backouts didn't work.) I did lots of web searches, without success.

I tried rebuilding the server one piece at a time, and found that the problem came from an XSD-generated class. My COM server sends WebService requests defined by an XSD file and I had used the VS2005 'xsd.exe' utility to generate C# classes represeting the WebService message structure. Simply including this file in my VS2005 project resulted in a DLL that caused the "No Such Interface" exception. So I commented the whole generated class and used the compiler to tell me which parts to uncomment (a tedious process). Luckily, it turned out that this fixed the problem. So there's something in the commented-out schema-generated class that's causing the exception. Or, conceivably, maybe the sheer size of the generated class is a problem, although it's "only" 14K lines or so.

Chalk this one up to "I don't know why it broke, but I found a workaround."

No comments: