Solved

COM & Errors

Posted on 1998-07-21
2
201 Views
Last Modified: 2013-11-25
I've got a COM server written in VC++ 5.0 with ATL whose target client is applications written in VB.  What I would love to do is throw an exception from the COM component and have standard error handling in VB be able to trap it.  This approach isn't working.  I'm having a hard time finding any documentation on this issue.  Please help.
0
Comment
Question by:rayb
2 Comments
 
LVL 1

Accepted Solution

by:
eburley earned 50 total points
ID: 1168208
support the ISupportErrorInfo interface, implementing InterfaceSupportsErrorInfo(riid) (ATL has an ISupportErrorInfoImpl which does this for you)

when an error happens:
Call CreateErrorInfo, passing the address of an
 ICreateErrorInfo * as the argument.

you can then use the functions in the ICreateErrorInfo object (SetDescription, SetGUID, SetHelpContext, SetHelpFile, SetSource) to populate the error.

when vb sees the error in IDispatch, it will call GetErrorInfo, then call InterfaceSupportsErrorInfo.  if your interface returns S_OK from this, vb will assume the error is legit, and use the information in the error object to inform the user.
0
 
LVL 2

Author Comment

by:rayb
ID: 1168209
Thanks

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now