How to debug applications using COM interfaces?
Question
I' building an application using C# which will use CATIA COM modules. When I import the COM inside my c# project, I think that Visual C# express generates the Interop automagically for me.
All of this works correctly. However, when I try to debug the application and use watches during runtime, every object is a System.__ComObject
and I cannot get their "real" value.
Is there a way to tell the debugger the types of my COM objects?
The goal is to get more familiar with this new API I don't know really well. Sometimes its rather hard to guess the correct types for everything since the interface hierarchy is quite deep
Solution
You don't post a code example where you have a problem. Mostly it's depend on how you create or cast a object which you want to see in Debugger (create an instance of the object with new
is always better, if it is possible of cause). You should search for information about Runtime Callable Wrapper (RCW). This is "the guy" who can not understand what you want.
By the way if you can use Visual Studio 2010 your live can be easer (see http://blogs.msdn.com/b/habibh/archive/2009/09/22/debugging-a-com-object-runtime-callable-wrapper-with-visual-studio-2010.aspx).
Two links can help you to solve the problem if you use
http://dotnetdebug.net/category/com-interop/
http://resources.esri.com/help/9.3/arcgisengine/dotnet/e6532ba4-d769-48a6-8bc4-8592352b9bf4.htm
Inspecting an instance of a COM / Interop class properly in VS.Net's debugger?
http://dotnetdebug.net/2005/09/10/runtime-callable-wrapper-internals-and-common-pitfalls/
OTHER TIPS
In visual studio if you open tools >> Options and then debugging >> General make sure the option "Use managed compatibility mode" it checked on. This should show com objects as their proper types in the debugger.