Solved

error propagaton from atl to C# client

Posted on 2004-04-15
3
288 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
visual Basic Net vs c# net 8 56
dynamic menu in asp.net c# 11 30
Events in static methods 3 27
COnsume rest client 6 12
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

758 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

16 Experts available now in Live!

Get 1:1 Help Now