By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,224 Members | 1,309 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,224 IT Pros & Developers. It's quick & easy.

is relection any good for late binding COM client

P: n/a
jg
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=" +
ToString(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
found

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?
Nov 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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:

http://msdn.microsoft.com/vbrun/vbfu...s/default.aspx
"jg" wrote:
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=" +
ToString(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
found

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?

Nov 21 '05 #2

P: n/a
jg
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?

"Scott Swigart" <sc***@swigartconsulting.com> wrote in message
news:D7**********************************@microsof t.com...
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:

http://msdn.microsoft.com/vbrun/vbfu...s/default.aspx
"jg" wrote:
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=" +
ToString(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
found

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?

Nov 21 '05 #3

P: n/a
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 ComClass.zip, 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

"jg" wrote:
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?

"Scott Swigart" <sc***@swigartconsulting.com> wrote in message
news:D7**********************************@microsof t.com...
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:

http://msdn.microsoft.com/vbrun/vbfu...s/default.aspx
"jg" wrote:
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=" +
ToString(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
found

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?


Nov 21 '05 #4

P: n/a
jg
Thank you. please resend the COM class zip by replying to my email I just
sent. The email address posted here is phoney.
"Scott Swigart" <sc***@swigartconsulting.com> wrote in message
news:03**********************************@microsof t.com...
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 ComClass.zip, 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

"jg" wrote:
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?

"Scott Swigart" <sc***@swigartconsulting.com> wrote in message
news:D7**********************************@microsof t.com...
> 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:
>
> http://msdn.microsoft.com/vbrun/vbfu...s/default.aspx
>
>
> "jg" wrote:
>
>> 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=" +
>> ToString(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
>> found
>>
>>
>>
>> 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?
>>
>>
>>


Nov 21 '05 #5

P: n/a
jg
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

"Scott Swigart" <sc***@swigartconsulting.com> wrote in message
news:03**********************************@microsof t.com...
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 ComClass.zip, 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

"jg" wrote:
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?

"Scott Swigart" <sc***@swigartconsulting.com> wrote in message
news:D7**********************************@microsof t.com...
> 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:
>
> http://msdn.microsoft.com/vbrun/vbfu...s/default.aspx
>
>
> "jg" wrote:
>
>> 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=" +
>> ToString(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
>> found
>>
>>
>>
>> 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?
>>
>>
>>


Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.