Raise Error to VB application

  • Thread starter Thread starter Alan Roberts
  • Start date Start date
A

Alan Roberts

I havean app written in vb6 that links to a vb6 DLL file. The app handles
errors raised by the DLL based on the error number (Err.Number). I would
now like to convert the DLL to c#. How can I raise errors from the c# DLL
so that the VB6 exe can diferentiate between them (eg using the old
Err.Number system)?

Thanks

Alan
 
Alan,

What you want to do in this situation is create your own class derived
from Exception. Once you do that, you can set the HResult property to the
value that corresponds to the number returned from Err.Number.

Hope this helps.
 
Alan,
How can I raise errors from the c# DLL
so that the VB6 exe can diferentiate between them (eg using the old
Err.Number system)?

throw Marshal.GetExceptionForHR(yourErrorCode);

where yourErrorCode is a HRESULT error code. Some HRESULTs will be
mapped to built-in VB error numbers and others are used as is.


Mattias
 
Back
Top