Solved

error propagaton from atl to C# client

Posted on 2004-04-15
3
290 Views
Last Modified: 2012-08-13
We are in the process of converting ATL clients to C#.
However,I have not been able to make errors to get progated properly.
I have read that teh ATL component is reqired to support the ISupportErrorInfo interface for erro propagation to work.
Subsquently here is the point where error is raised from a ATL dll
else
{
CreateErrorInfo(&pErrorInfo);
            if(hSuccess)
            {
                  pErrorInfo->SetGUID(IID_IAirlineInfoObj);
                  pErrorInfo->SetDescription(SysAllocString(L"Data not found"));
                  IErrorInfo* _errInfo=NULL;
                  hSuccess=pErrorInfo->QueryInterface(IID_IErrorInfo,(void**)&_errInfo);
                  if(hSuccess)
                  {
                        SetErrorInfo(0,_errInfo);
                  }
            }
            return E_FAIL;
}
And the C# client tries to trap it as follows
catch(Exception e)
                  {
                           
                        Console.WriteLine( " The exception is {0}",System.Runtime.InteropServices.Marshal.GetHRForException(e));  
                  }
This does not work.How do i retrieve the data I had set on the IErrorInfo interface in the COM server?

0
Comment
Question by:ranadhir
3 Comments
 
LVL 10

Accepted Solution

by:
ptmcomp earned 25 total points
ID: 10846274
Catch(ComException e)
{
    Console.WriteLine( " The exception is {0}", e.ErrorCode);
}
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

815 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

12 Experts available now in Live!

Get 1:1 Help Now