473,396 Members | 2,158 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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
Sep 3 '08 #1
1 2174
Hi Mike,
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
Sep 3 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Damaji Jambhale | last post by:
COMException: Catostrphic failure When I added a "dll" reference in the web project. I was able to instantiate the class OK. But when I tried to set the properties, it failed with...
2
by: Alex Vinokur | last post by:
------------------------ Visual C++ 6.0 Debug Mode ----------------------- I have the following piece of code: ================ int* p;
1
by: Steven | last post by:
Hi there, I am trying to export a chart using the Excel11 object from C#. I can properly open workbooks and read cells, but calling Export() on the Chart object throws a COMException ...
3
by: Jay A. Moritz | last post by:
I have an application that loads IE and iterates through web pages to retrieve information from the page then activates specific controls to retrieve the next page and iterate through that page for...
0
by: Hexman | last post by:
I have this app that during one step of the process just adds data records from a .txt file into an Access database. I want to be able to reprocess the entire .txt file (if necessary - one reason...
2
by: Eric Lilja | last post by:
Hello, consider this complete program: #include <iostream> #include <string> using std::cout; using std::endl; using std::string; class Hanna {
5
by: cj | last post by:
When I run myMAPIMessage.Send(True) if the user cancels the resulting email it causes an exception. How do I trap this particular exception and say that's ok? try myMAPIMessage.Send(True)...
2
by: fischermx | last post by:
Exception Catching difference between VC++ and C# In C# I have this: try { int x, y, z; x = 20; y = 0;
2
by: ortega23 | last post by:
Hi, I am trying to obtain the column number of the parent of a cell, if the cell is a linked cell (i.e. its value depends on another cells value). I try to read "Precedents"(parent cells) of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.