I often work with a variety of tools and development platforms. Recently, I have been working on VB.NET project for a client’s flagship product, a business management software weighing in at 92 million lines of code. The project interacts with a large data model represented by a hierarchy of VB6 objects exposing COM interfaces.
Fortunately, Microsoft’s development tools include support for fairly transparent and ostensibly hassle-free inter-operation with COM object. Unfortunately, the inter-operation is often fraught with hassles. One problem with COM that crops up in a variety of situations recently occurred on this project:
The callee (server [not server application]) is not available and disappeared; all connections are invalid. The call may have executed. (Exception from HRESULT: 0x80010007 (RPC_E_SERVER_DIED))
In my particular case, a COM object was stored in a Shared class variable in a Singleton pattern. Sometimes when accessing the Singleton, this error would occur. Since the Singleton is stateless, there is a simple but ugly solution that works reliably. The solution, ugly as it is, was to detect this circumstance, and, if the exception occurs, clear the Singleton and create a new one.