How to make a DLL usable from VB6

  • Thread starter Thread starter AussieRules
  • Start date Start date
A

AussieRules

Hi,
I have been trying to build a DLL in vb2008, that can be called from a VB6
application.. So far I have got the DLL to be registered on the VB6 machine
ok, but it can't see any of my interfaces/functions.

So I figure my class is configured ok, but the functions are not.. (I have
the COMM Class and COM Visible set to true for the properties of the class).
I also have under the project/properties.compile option of Register for COM
interop set as well...

Can anybody give me a tip on what is wrong with this code..

Thanks...

<ComClass(TestClass.ClassId, TestClass.InterfaceId, TestClass.EventsId)> _
Public Class TestClass

#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 = "d41b9efd-ce16-48df-bab4-16352d47b669"
Public Const InterfaceId As String =
"bd2b42e6-4e8b-4195-82e6-c3dd7c6b4bbb"
Public Const EventsId As String = "1f0dbdf5-5509-4e4f-aaf6-631572881186"
#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()
End Sub
Public Shared Function GetValue(ByVal intShelfID As Integer) As Integer

GetValue= 99
Return GetValue

End Function

Public Shared Function ValueID()
Return 1

End Function
End Class
 
Am 10.06.2010 15:28, schrieb AussieRules:
Hi,
I have been trying to build a DLL in vb2008, that can be called from a VB6
application.. So far I have got the DLL to be registered on the VB6 machine
ok, but it can't see any of my interfaces/functions.

So I figure my class is configured ok, but the functions are not.. (I have
the COMM Class and COM Visible set to true for the properties of the class).
I also have under the project/properties.compile option of Register for COM
interop set as well...

Can anybody give me a tip on what is wrong with this code..

Thanks...

<ComClass(TestClass.ClassId, TestClass.InterfaceId, TestClass.EventsId)> _
Public Class TestClass

#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 = "d41b9efd-ce16-48df-bab4-16352d47b669"
Public Const InterfaceId As String =
"bd2b42e6-4e8b-4195-82e6-c3dd7c6b4bbb"
Public Const EventsId As String = "1f0dbdf5-5509-4e4f-aaf6-631572881186"
#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()
End Sub
Public Shared Function GetValue(ByVal intShelfID As Integer) As Integer

GetValue= 99
Return GetValue

End Function

Public Shared Function ValueID()
Return 1

End Function
End Class

I only see shared members in this class. Therefore there is nothing to expose.

"...static methods [...] are not exposed to COM clients". Source:
http://msdn.microsoft.com/en-us/library/7fcfby2t(VS.90).aspx
 
Hi Armin,

Thanks for your reply... I have tried to find the proper way to declare my
function so that they are exposed, but no luck...

Could I ask for your assistance and have you just show me the correct code
to expose my functions...

Thanks heaps for this..

Thanks


Armin Zingler said:
Am 10.06.2010 15:28, schrieb AussieRules:
Hi,
I have been trying to build a DLL in vb2008, that can be called from a
VB6
application.. So far I have got the DLL to be registered on the VB6
machine
ok, but it can't see any of my interfaces/functions.

So I figure my class is configured ok, but the functions are not.. (I
have
the COMM Class and COM Visible set to true for the properties of the
class).
I also have under the project/properties.compile option of Register for
COM
interop set as well...

Can anybody give me a tip on what is wrong with this code..

Thanks...

<ComClass(TestClass.ClassId, TestClass.InterfaceId, TestClass.EventsId)>
_
Public Class TestClass

#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 =
"d41b9efd-ce16-48df-bab4-16352d47b669"
Public Const InterfaceId As String =
"bd2b42e6-4e8b-4195-82e6-c3dd7c6b4bbb"
Public Const EventsId As String =
"1f0dbdf5-5509-4e4f-aaf6-631572881186"
#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()
End Sub
Public Shared Function GetValue(ByVal intShelfID As Integer) As
Integer

GetValue= 99
Return GetValue

End Function

Public Shared Function ValueID()
Return 1

End Function
End Class

I only see shared members in this class. Therefore there is nothing to
expose.

"...static methods [...] are not exposed to COM clients". Source:
http://msdn.microsoft.com/en-us/library/7fcfby2t(VS.90).aspx
 
Am 14.06.2010 17:07, schrieb AussieRules:
Hi Armin,

Thanks for your reply... I have tried to find the proper way to declare my
function so that they are exposed, but no luck...

Could I ask for your assistance and have you just show me the correct code
to expose my functions...

Thanks heaps for this..

Did you understand why they are not exposed?
 
Hi,

No I don't. I have read the article, but its above my head on what it all
means...

I would have thought that 'public shared' would have at least meant it was
exposed to outside world, but that seems not the case...

I just need to be pointed in the right direction and shown how to do this,
then it will probably click for me...

I am under the pump to get this done in the next day or so, so thanks for
your assitance on this one..

Thanks..
 
Am 15.06.2010 00:58, schrieb AussieRules:
Hi,

No I don't. I have read the article, but its above my head on what it all
means...

I would have thought that 'public shared' would have at least meant it was
exposed to outside world, but that seems not the case...

I just need to be pointed in the right direction and shown how to do this,
then it will probably click for me...

I am under the pump to get this done in the next day or so, so thanks for
your assitance on this one..

Don't make the methods Shared. Make them instance members. (remove "Shared").
 
Thanks for that.. it works a treat.....


Armin Zingler said:
Am 15.06.2010 00:58, schrieb AussieRules:

Don't make the methods Shared. Make them instance members. (remove
"Shared").
 
Back
Top