Hi all.
I'm writing some .net compoents that are also going to be used from vb6
code. Is there a way for me to distinguish all the different types of
exceptions that the .net code my throw ? My .net component can throw a few
different types of exceptions and I need my vb6 code to take action
differently based on which exception it comes accross.
Can I set the error number somehow on my exception classes? (maybe an
attribute ?)
I'd like my vb6 code to look like:
private Sub MySub()
On Error Goto ErrHandling
dim myDotnetObj as DotNetComponent.Class1
set myDotNetObj = new DotNetcomponent.Class1
myDotNetObj.CallMethod()
Exit Sub
ErrHandling:
Select Case err.Number
Case 123: doSomething1
Case 456: doSomething2
End Select
End Sub
TJoker .NET,
Check out the section of the .NET framework documentation titled
"HRESULTs and Exceptions", located at (watch for line wrap):
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cp
conhresultsexceptions.asp
In it, you will see that certain exceptions map to certain HRESULT error
codes. For your own exceptions, you can override the HResult property to
return an error code for when this exception is marshaled as a COM error
code.
Hope this helps.

Signature
- Nicholas Paldino [.NET/C# MVP]
- nicholas.paldino@exisconsulting.com
> Hi all.
> I'm writing some .net compoents that are also going to be used from vb6
[quoted text clipped - 22 lines]
>
> End Sub
TJoker .NET - 07 Jul 2003 20:50 GMT
Thanks, Nicholas. That helped me a lot.
Another question: Do I have to put Guid attributes on my exception classes ?
I got some strange Automation Error errors on my VB6 code before adding the
Guid attributes, but that could have been a coincidence.
Thanks
TJ
> TJoker .NET,
>
> Check out the section of the .NET framework documentation titled
> "HRESULTs and Exceptions", located at (watch for line wrap):
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
l/cpconhresultsexceptions.asp
> In it, you will see that certain exceptions map to certain HRESULT error
> codes. For your own exceptions, you can override the HResult property to
[quoted text clipped - 33 lines]
> >
> > End Sub