473,396 Members | 1,852 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

is relection any good for late binding COM client

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
5 1592
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Olaf Meding | last post by:
Is there a way to find out if I am using early or late binding given the reference ("excel" in the example below) returned by Dispatch()? >>> import win32com.client >>> excel =...
21
by: Mike MacSween | last post by:
Had some trouble with Word automation. Sorted it, in the process thought I would try late binding. Some people reccomend it. So this: *********************************************************...
9
by: Zlatko Matić | last post by:
I was reading about late binding, but I'm not completely sure what is to be done in order to adjust code to late binding... For example, I'm not sure if this is correct: early binding: Dim ws...
2
by: cmrchs | last post by:
Hi, is it possible to instantiate an object on a remote server using late-binding ? (so the client does not need the info at compile time.) I look at remoting, but all those methods 'force'...
9
by: John Smith | last post by:
Hey, I'm having a difficult time finding some good examples of late binding Outlook in C#. Anyone know of any good sites out there? I've googled and MSDN'ed, but have come up a bit empty. ...
3
by: gregory_may | last post by:
I want to prevent late binding of this statement: MyServerConnections(Myindex).client = Value But when I try with the code below, I get an editor error: "Expression is a value and therefor...
6
by: Tim Roberts | last post by:
I've been doing COM a long time, but I've just come across a behavior with late binding that surprises me. VB and VBS are not my normal milieux, so I'm hoping someone can point me to a document...
2
by: kogrover | last post by:
ISSUE: COM Excel Sort works with Early Binding, but not Late Binding, but py2exe only does Late Binding I have code similar to this (type from notes, so there may be a typo...) import...
5
by: b00n1 | last post by:
I'm trying to create a simple vb.net (server) dll, and then through late binding access the public methods of the contained class from another vb.net (client) app. I can do it through early...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.