Solved

error propagaton from atl to C# client

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Performance  Html.BeginForm vs jQuery 3 45
c# string handling 1 26
Excel file not created as expected 7 46
Reset asp.net login password 4 24
Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
A short film showing how OnPage and Connectwise integration works.
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

943 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

7 Experts available now in Live!

Get 1:1 Help Now