Hey zyphax, I know this is about two weeks later, but I was looking around some sites for some code and happened upon this one. If the vb
.net dll/class is going to be exposed through COM then here is how I do it. The way I've been doing it recently works great, but I am not sure if it is all needed.
first import InteropServices
second make an Interface.
If you don't know what it is or does...
It is where you define the headers for all functions, subs, and properties that will be exposable to COM.
<Guid("[Generate a GUID in VS.net and put it here]"), _
Public Interface _main
'this is where you declare functionc, subs, and properties
'something like this
<DispId(1)> Function GetVolume() As String
<DispId(2)> Sub SetVolume(ByVal newvalue As String)
the format for the GUID should be
third you create a class that Implements the Interface.
when you Implement an Interface the class handles all the functions, subs and properties in the Interface. Basically it is where you perform operations on the data from the Interface and send data back through the Interface.
This is also ehre you can declear the object name that will be registered to COM so you can call the dll/class.
The ProgId is the object name.
In this example the class Sound is one I created.
<Guid("[Generate another GUID in VS.net and put it here]"), _
ProgId("[Obj Nmn]")> _
Public Class main
Private snd As New Sound
Public Function GetVolume() As String Implements _main.GetVolume
Public Sub SetVolume(ByVal newvalue As String) Implements _main.SetVolume
Next wrap the the Implement and Class in a Namespace.
This is simple just put
Namespace [Replace with name]
before the Implement and
after the class.
Last The important one. register the Dll for COM InterOp
I played around for a really, i mean really long time before I found this way of doing it.
It is simple.
Open the Solution Explorer for the current Project.
select the Project Node. then Right Click it. Choose Properties.
when the dialog opens there will be a TreeView with Common Properties and Configuration Properties as the main nodes.
Choose Configuration Properties then the Child Node, Build.
In Build there will be a checkbox that has the text Register for COM Interop. Check it.
Now you can compile the dll/class and it will register it for you.
after that you should be able to call the dll/class from and COM client.