471,603 Members | 1,477 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,603 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 2583
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by noone | last post: by
21 posts views Thread by Mike MacSween | last post: by
13 posts views Thread by Mike MacSween | last post: by
7 posts views Thread by PC Datasheet | last post: by
9 posts views Thread by Zlatko Matić | last post: by
9 posts views Thread by John Smith | last post: by
30 posts views Thread by lgbjr | last post: by
reply views Thread by MichaelMortimer | last post: by
reply views Thread by CCCYYYY | last post: by

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.