is relection any good for late binding COM client



I followed the pattern in the MSDN dot net example for .net server and I
tried a making simple .net dll as COM from
Option Explicit On

Option Strict On

Imports System

Imports System.Text.RegularExpressions

Imports System.Text.Encoding

Imports System.Reflection

Public Interface ISomeClass

' Property OpeningBalance() As Double

Function test(ByVal strIn As String, ByVal intIn As Integer) As String

End Interface

Public Class SomeClass

Implements ISomeClass

Public Sub New()

End Sub

Public Function test(ByVal strIn As String, ByVal intIn As Integer) As
String _

Implements ISomeClass.test

Dim lstr_test As String

lstr_test = "input string received: " + strIn + "\l\f intIn=" +

Return lstr_test

End Function

End Class

I "built" the dll with Class template, Assmely Name as SomeClass, and
rootspace name as SomeClass, Startobject being (none) with Visual studio
2005 express for visul basic.

I also registered the typelib

regasm SomeClass.dll /tlb:SomClass.tlb

The vbscript is in the same directory of the dll and typlib. The code is

Dim objSomeClass

set objSomeClass = CreateObject("SomeClass.ISomeClass") <= error not

Dim ll_pos, lstr_result

ll_pos = 999

lstr_result = objSomeClass.test("TestIn", ll_pos)

wscript.msgbox "result="& lstr_result , vbOKOnly, "test SomeClass"

What can I do to make it work? Or the I sould not have used relection at
all but use explicit marshalling for late binding client?




If I understand you correctly, you're trying to call a .NET class like it's a
COM object, correct? If so, I have an article series on MSDN that talks
about doing exactly that.

In specific, when you create your .NET class, instead of just adding a class
to your VB.NET project, you should add a COM Class. This makes it so that
your .NET class can be easilly registered as a COM object, and your VB Script
should be able to find it just fine. Check out the walk-through about 1/2
way down in this article:


Thank you very much, Right on, I do want to call a .net class like COM

My vstudio express 2005 does not have COM class. what can I edit in terms of
the project file to get the same result?


The ComClass template from Visual Studio 2005 can be used just fine in VB
Express. It doesn't look like I can post attachments here, so I'll send it
to you as a private e-mail. When you get the, simply drop it
into My Documents\Visual Studio 2005\Templates\Item Templates\Visual Basic.
From then on, the Com Class will show up as an item you can add to projects.

Note, don't unzip it. Just drop the entire zip into that folder.

Scott Swigart - MVP


Thank you. please resend the COM class zip by replying to my email I just
sent. The email address posted here is phoney.




Com Class template helped after I manually clean up the registry dusts from
previous attempts
So now I will be ready to take on a real com project once I clean up the
registry dust from the futile efforts of previous attempts.

Hamm, wonder if some has created a .net project for cleanup classes and
clsid from failed .net projects


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