473,411 Members | 2,068 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,411 software developers and data experts.

Late binding to access COM+

Hi all,

I have two objects in my COM+ that I can't add the references to my project.
It has to use late binding in C#. For my applications in vb.net, I can solve
the problem using the code below. However, the late binding should be in C#.
How can I solve the problem?

Dim o As Object
Dim rs As ADODB.Recordset / databaset

o = CreateObject("Component.Class1")
rs = o.Load("SELECT * FROM Customer")
o = Nothing

How can I apply this code to C#?

Thanks in advance,
Wonder
Feb 13 '06 #1
2 2655
Wonder,

The proper way to do this is to create an interface that your COM+ class
implements. Then, you would create the instance as you would normally
(through CreateInstance) and then cast it to the interface.

You shouldn't be making late bound calls like this. Interfaces are an
easy way to prevent you from having to do that. The key is defining the
interface in an assembly separate from the implementation (the
implementation is what is registered).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Wonder" <Wo****@discussions.microsoft.com> wrote in message
news:08**********************************@microsof t.com...
Hi all,

I have two objects in my COM+ that I can't add the references to my
project.
It has to use late binding in C#. For my applications in vb.net, I can
solve
the problem using the code below. However, the late binding should be in
C#.
How can I solve the problem?

Dim o As Object
Dim rs As ADODB.Recordset / databaset

o = CreateObject("Component.Class1")
rs = o.Load("SELECT * FROM Customer")
o = Nothing

How can I apply this code to C#?

Thanks in advance,
Wonder

Feb 14 '06 #2
Thanks for the help. Could you help me with your explanation giving me an
example of that?

Thanks,
"Nicholas Paldino [.NET/C# MVP]" wrote:
Wonder,

The proper way to do this is to create an interface that your COM+ class
implements. Then, you would create the instance as you would normally
(through CreateInstance) and then cast it to the interface.

You shouldn't be making late bound calls like this. Interfaces are an
easy way to prevent you from having to do that. The key is defining the
interface in an assembly separate from the implementation (the
implementation is what is registered).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Wonder" <Wo****@discussions.microsoft.com> wrote in message
news:08**********************************@microsof t.com...
Hi all,

I have two objects in my COM+ that I can't add the references to my
project.
It has to use late binding in C#. For my applications in vb.net, I can
solve
the problem using the code below. However, the late binding should be in
C#.
How can I solve the problem?

Dim o As Object
Dim rs As ADODB.Recordset / databaset

o = CreateObject("Component.Class1")
rs = o.Load("SELECT * FROM Customer")
o = Nothing

How can I apply this code to C#?

Thanks in advance,
Wonder


Feb 15 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: noone | last post by:
I like to write my code with optionstrict set to on, except for the late binding errors I get when there is a reason to change some value in a control on a postback, like: Label4.Text =...
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: *********************************************************...
13
by: Mike MacSween | last post by:
I'm doing this: strAccessPath = SysCmd(acSysCmdAccessDir) & "msaccess.exe" in a vb executable to do what it looks like. If I remove the reference to the access object library this seems to...
7
by: PC Datasheet | last post by:
I have this: Dim Cbr As Object Dim Ctl As Object Set Cbr = Application.Commandbars("CourseCalendarMonth") Set Ctl = Application.Commandbars("CourseCalendarMonth").Controls("CalendarMonth") Is...
14
by: Composer | last post by:
I've read many postings about the problem of Access.References.IsBroken and the consensus seems to be that late binding is the cure-all. I have a very complex Access application that needs...
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...
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. ...
30
by: lgbjr | last post by:
hi All, I've decided to use Options Strict ON in one of my apps and now I'm trying to fix a late binding issue. I have 5 integer arrays: dim IA1(500), IA2(500), IA3(500), IA4(500), IA5(500) as...
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...
3
ADezii
by: ADezii | last post by:
The process of verifying that an Object exists and that a specified Property or Method is valid is called Binding. There are two times when this verification process can take place: during compile...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.