error propagaton from atl to C# client

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
                  pErrorInfo->SetDescription(SysAllocString(L"Data not found"));
                  IErrorInfo* _errInfo=NULL;
            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?

Who is Participating?
ptmcompConnect With a Mentor Commented:
Catch(ComException e)
    Console.WriteLine( " The exception is {0}", e.ErrorCode);
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.