ranadhir nag
April 15th, 2004, 10:29 PM
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?
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?