?
Solved

COM & Errors

Posted on 1998-07-21
2
Medium Priority
?
212 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
eburley earned 200 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
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.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

800 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