How to make a DLL usable from VB6


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
 
Ad

Advertisements

A

Armin Zingler

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
 
A

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..

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
 
A

Armin Zingler

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?
 
A

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..

Thanks..
 
A

Armin Zingler

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").
 
Ad

Advertisements

A

AussieRules

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").
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top