|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Use of the number of ErrObject in VB6 through a dll made in VB .NEI 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 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 > 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
MS's Excruciating Update Cycles
Datagrid with VB 2005 Datagrid problem large arrays and system.outofmemoryexception Late Binding Question DataBinding and Combo Boxes Problems with TCP Listener select all text when textbox1 is clicked Auto-stop DUN via VB.Net? Is it possible to use Field Names instead of Item(0) with Data Row using VB.Net 2005 ? |
|||||||||||||||||||||||