How to debug applications using COM interfaces?
I'm 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" 开发者_JAVA技巧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 it's rather hard to guess the correct types for everything since the interface hierarchy is quite deep.
You don't post a code example where you have a problem. Mostly it's depend on how you create or cast an object which you want to see in Debugger (create an instance of the object with new
is always better, if it is possible of course). 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 life can be easier (see Link).
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/
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.
精彩评论