We have a WinForms application where we have to use COM to interface with Excel and/or PowerPoint (I know, COM objects are a major hassle, and I'd like to not have to use them at all, but at least for now we have no choice).
Some machines which will be running this app also have a custom VSTO COM Add-in installed within Excel and/or PowerPoint 2007. This add-in works fine and as expected; it loads when the Office app starts, does not crash, and appears to have sufficient exception handling. This VSTO Add-in is developed by our company, so we have the source code available to make changes if needed.
The problem manifests itself when the COM object in the WinForms app is declared in code. Once the connection to that object is made, whichever Office app is being connected to (Excel or PowerPoint) will throw a cryptic error, usually along the lines of RPC Server Unavailable.
We have found that if we simply disable the VSTO Add-in within Excel/PowerPoint, the problem goes away. Obviously the VSTO Add-in is executing at startup, but we cannot find any exception(s) within the VSTO Add-in which would cause Excel/PowerPoint to throw an error.
So as a hack to get around the issue, we can programmatically disable any active Add-ins before the connection to the COM object is made, and then re-enable when finished. But we'd much prefer to get this solved the right way if possible.
I realize this is perhaps a niche area, intermixing VSTO Add-ins and COM objects through code in a separate app, but am hopeful we are missing an obvious solution.