bmutch
asked on
Possible to pass object from vb.net program to vb6 executable?
Is there any way to pass an object from a vb.net program to a vb6 executable. I am currently passing some data in command line parameters to it, but I would like to pass in the whole "customer" object because I have made it an interop class and so the same class exists in the vb6 project. I could then just set the vb6 object equal to the passed in object from dotnet and be on my way.
thanks,
Bruce Mutch
thanks,
Bruce Mutch
ASKER
To explain further, I have a Customer object and a child ReportCollection object in dotnet that I can access fine. When I pass the Customer object to the vb6 dll, the child ReportCollection object is "Nothing": here is the code for the child object ReportCollection:
( do you think the problem is due to the "Inherits Hashtable". I had to use this so I could refer to the report objects in the ReportCollection by string keys)
<ComClass(ReportCollection .ClassId, ReportCollection.Interface Id, ReportCollection.EventsId) > _
Public Class ReportCollection
Inherits Hashtable
#Region "COM GUIDs"
' These GUIDs provide the COM identity for this class
' and its COM interfaces. If you change them, existing
' clients will no longer be able to access the class.
Public Const ClassId As String = "22CB3A25-EE3F-41bb-8B20-F E6E414BA37 2"
Public Const InterfaceId As String = "2B8026B3-7E25-4014-8AD5-6 775A6C351D 2"
Public Const EventsId As String = "2BA1C216-DA58-4531-8211-D D02FBFB5D9 2"
#End Region
'Inherits NameValueCollection
'Inherits CollectionBase
Public Sub New()
End Sub
Default Public ReadOnly Property GetItem(ByVal Index As Object) As Report
Get
Return CType(Me.Item(Index), Report)
End Get
End Property
Public Sub AddReport(ByVal _Item As Report)
Me.Add(_Item.Name, _Item)
End Sub
End Class
( do you think the problem is due to the "Inherits Hashtable". I had to use this so I could refer to the report objects in the ReportCollection by string keys)
<ComClass(ReportCollection
Public Class ReportCollection
Inherits Hashtable
#Region "COM GUIDs"
' These GUIDs provide the COM identity for this class
' and its COM interfaces. If you change them, existing
' clients will no longer be able to access the class.
Public Const ClassId As String = "22CB3A25-EE3F-41bb-8B20-F
Public Const InterfaceId As String = "2B8026B3-7E25-4014-8AD5-6
Public Const EventsId As String = "2BA1C216-DA58-4531-8211-D
#End Region
'Inherits NameValueCollection
'Inherits CollectionBase
Public Sub New()
End Sub
Default Public ReadOnly Property GetItem(ByVal Index As Object) As Report
Get
Return CType(Me.Item(Index), Report)
End Get
End Property
Public Sub AddReport(ByVal _Item As Report)
Me.Add(_Item.Name, _Item)
End Sub
End Class
ASKER
changed the collection class code and it works perfectly now.
<ComClass(ReportCollection .ClassId, ReportCollection.Interface Id, ReportCollection.EventsId) > _
Public Class ReportCollection
Private mCol As Collection
#Region "COM GUIDs"
' These GUIDs provide the COM identity for this class
' and its COM interfaces. If you change them, existing
' clients will no longer be able to access the class.
Public Const ClassId As String = "BCECC526-BC69-415C-8F1A-2 F1CBB1D0F5 0"
Public Const InterfaceId As String = "5C76AB26-729D-4E32-8AC1-5 A19E494ADC E"
Public Const EventsId As String = "CB1884B0-9B7C-4049-BC10-0 34A0512A19 6"
#End Region
' A creatable COM class must have a Public Sub New()
' with no parameters, otherwise, the class will not be
' registered in the COM registry and cannot be created
' via CreateObject.
Public Sub New()
MyBase.New()
mCol = New Collection()
End Sub
Public Sub Add(ByVal oItem As Report, ByVal sKey As String)
mCol.Add(oItem, sKey)
End Sub
Public Sub Remove(ByVal sKey As String)
Try
mCol.Remove(sKey)
Catch ex As Exception
Throw ex
End Try
End Sub
Default Public ReadOnly Property Item(ByVal Index As String) As Report
Get
Return mCol(Index)
End Get
End Property
Public Function GetEnumerator() As System.Collections.IEnumer ator
'return our internal collection's IEnumerator.
'COM calls this function when the collection is enumerated using the For-Each syntax
Return mCol.GetEnumerator
End Function
End Class
<ComClass(ReportCollection
Public Class ReportCollection
Private mCol As Collection
#Region "COM GUIDs"
' These GUIDs provide the COM identity for this class
' and its COM interfaces. If you change them, existing
' clients will no longer be able to access the class.
Public Const ClassId As String = "BCECC526-BC69-415C-8F1A-2
Public Const InterfaceId As String = "5C76AB26-729D-4E32-8AC1-5
Public Const EventsId As String = "CB1884B0-9B7C-4049-BC10-0
#End Region
' A creatable COM class must have a Public Sub New()
' with no parameters, otherwise, the class will not be
' registered in the COM registry and cannot be created
' via CreateObject.
Public Sub New()
MyBase.New()
mCol = New Collection()
End Sub
Public Sub Add(ByVal oItem As Report, ByVal sKey As String)
mCol.Add(oItem, sKey)
End Sub
Public Sub Remove(ByVal sKey As String)
Try
mCol.Remove(sKey)
Catch ex As Exception
Throw ex
End Try
End Sub
Default Public ReadOnly Property Item(ByVal Index As String) As Report
Get
Return mCol(Index)
End Get
End Property
Public Function GetEnumerator() As System.Collections.IEnumer
'return our internal collection's IEnumerator.
'COM calls this function when the collection is enumerated using the For-Each syntax
Return mCol.GetEnumerator
End Function
End Class
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks.