By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,515 Members | 1,110 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,515 IT Pros & Developers. It's quick & easy.

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

P: n/a
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

Mar 29 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
can anybody help please ?

"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

Apr 4 '06 #2

P: n/a
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

Apr 5 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.