Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old September 3rd, 2008, 06:15 PM
TheFid
Guest
 
Posts: n/a
Default Catching a C# COMException in VC++ 6

In case someone knows off the top....

I am accessing a COM-interface-exposing C# dll in VC++ 6. The C# disp
method can throw a COMException.

Do I catch a _com_error ? It's not obvious from the docs.

TIA,
Mike
  #2  
Old September 3rd, 2008, 06:55 PM
SvenC
Guest
 
Posts: n/a
Default Re: Catching a C# COMException in VC++ 6

Hi Mike,
Quote:
In case someone knows off the top....
>
I am accessing a COM-interface-exposing C# dll in VC++ 6. The C# disp
method can throw a COMException.
>
Do I catch a _com_error ? It's not obvious from the docs.
That depends on how your VC++ 6 code looks like.

COM itself when it comes down to calling methods on interfaces uses
HRESULTs (32 bit numbers) to return error information. There are
"extensions" like IErrorInfo or EXCEPINFO which you can lookup
if you want.

The language you use COM in might add/integrate its error handling
concepts.

In VC++ you can use #import "typelib/progid/clsid" to auto generate
tli/tlh pairs where HRESULT can be translated to C++ exceptions
based on _com_error. You should catch(_com_error& ex) in this case.
Please recognize the & to avoid the creation of temporary copies of
the thrown object instance.

If you use the MFC class wizard to create COM client wrapper classes,
it uses another concept of giving you error information. I didn't use it
for ages, so I do not know anymore if they gave you the HRESULT or
did also encapsulate the error in some MFC COM error class.

--
SvenC
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles