Home All Groups Group Topic Archive Search About

Use of the number of ErrObject in VB6 through a dll made in VB .NE

Author
29 Mar 2006 8:40 AM
Slimane
Hi,

I try to use the ErrObject in one of my class Library. The class Library is
written in VB .NET and the dll should be used in a VB6 application or a VB
..NET application.

Here is a simple example of the code I wrote in .NET:

Public Class Class1
    Public Sub test()
        Err.Raise(777,,"test description", "test help link")
    End Sub

    Public Sub test2()
        Err.Raise(888,,"test description2", "test help link2")
    End Sub

    Public Sub test3()
        Err.Raise(999)
    End Sub
End Class

And now here is my problem.

When I catch the error in .NET (using On Error), I have access to the
description and to the help file link. But, no matter what error number I
use, the program written in VB 6 always has the same error number.

This number is: -2146233088.

After googling it, I found a post which says that this is a COM error
exception: "managed code casting unhandled exception".

So, my question is: How do I use the number attribute of the ErrObject ?

Remark: when I use the Dll in VB .NET, I catch the correct number.

Thanks in advance for any help or any pointer.

For the record, here is a sample of a VB 6 code that I use to catch the error:

Private Sub Form_Load()
    On Error GoTo there
    MsgBox ("test")
    Dim tst As ErrorVB6.Class1
    Set tst = New Class1
    tst.Test
there:
    MsgBox (Err.Number & ":" & Err.Description & "-" & Err.HelpFile)
End Sub

Author
4 Apr 2006 12:37 PM
Slimane
can anybody help please ?

Show quoteHide quote
"Slimane" wrote:

> Hi,
>
> I try to use the ErrObject in one of my class Library. The class Library is
> written in VB .NET and the dll should be used in a VB6 application or a VB
> .NET application.
>
> Here is a simple example of the code I wrote in .NET:
>
> Public Class Class1
>     Public Sub test()
>         Err.Raise(777,,"test description", "test help link")
>     End Sub
>
>     Public Sub test2()
>         Err.Raise(888,,"test description2", "test help link2")
>     End Sub
>
>     Public Sub test3()
>         Err.Raise(999)
>     End Sub
> End Class
>
> And now here is my problem.
>
> When I catch the error in .NET (using On Error), I have access to the
> description and to the help file link. But, no matter what error number I
> use, the program written in VB 6 always has the same error number.
>
> This number is: -2146233088.
>
> After googling it, I found a post which says that this is a COM error
> exception: "managed code casting unhandled exception".
>
> So, my question is: How do I use the number attribute of the ErrObject ?
>
> Remark: when I use the Dll in VB .NET, I catch the correct number.
>
> Thanks in advance for any help or any pointer.
>
> For the record, here is a sample of a VB 6 code that I use to catch the error:
>
> Private Sub Form_Load()
>     On Error GoTo there
>     MsgBox ("test")
>     Dim tst As ErrorVB6.Class1
>     Set tst = New Class1
>     tst.Test
> there:
>     MsgBox (Err.Number & ":" & Err.Description & "-" & Err.HelpFile)
> End Sub
>
Author
5 Apr 2006 7:06 PM
aaron.kempf
you sure that you're not having an err.number = 0 problem?

Private Sub Form_Load()
    On Error GoTo there
    MsgBox ("test")
    Dim tst As ErrorVB6.Class1
    Set tst = New Class1
    tst.Test
cleanexit:
    exit sub
there:
    MsgBox (Err.Number & ":" & Err.Description & "-" & Err.HelpFile)
End Sub



i wish i could be more help; i'm way over my head on .net error handling