473,409 Members | 1,935 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,409 software developers and data experts.

Late Binding to a Imported Interface

Jim
Hey all

I'm trying to late bind a VB6 object in Component Services using c#. I've been able to do tons of late binding, but now that I have a com+ object that doesn't have a method exposed directly, I'm having tons of trouble. (lots of research, lots of newsgroups, but no success!

I have an existing COM+ object "Company.Person" which has several interfaces. To load my object, I have to invoke a method that is "Imported" to "Person", the main interface (via the imported interface, IUser).

When late binding, this interface doesn't appear to be accessible. How do I invoke the "Load" method on IUser to populate my Company.Person object

Attempted Code

Type myUserType= Type.GetTypeFromProgID("Company.Person")
object objMyUser = Activator.CreateInstance(myUserType)

// parameters needed to load objMyUse
object[] parameter = new object[2]
parameter[0]=m_strDBConn
parameter[1]="GeorgePBurdell";

//I've tried this with 8 gazillion different BindingFlags combinations...
// I haven't found any great docs on the differences between the flag
myUserType.InvokeMember("Load"
BindingFlags.Public | BindingFlags.Static
BindingFlags.NonPublic |BindingFlags.Instance | BindingFlags.DeclaredOnly
BindingFlags.InvokeMethod, null, objMyUser, parameter)

When I try to InvokeMember on the "Load" command, I get the dreaded mscorlib.dll error, with the extremely helpful, "unknown name" description

Any code snippets would be great
Thanks
Jim
Nov 16 '05 #1
1 2820
Jim
From a contact at Microsoft:

"...if I read this right, he’s trying to late bind to a non-default interface. <b>You can’t do that</b>. Well, you can, but you have to hack the com object image, and that’s a bad idea.

For this kind of thing, the easiest solution is probably to build a broker class in VB6, hang a public method off of it, and let that public method QI and call Load on the other component. Call it a poor man’s class factory. May not be overly elegant, but for these kinds of issues, its usually easier to just drop a layer in there."

----- Jim wrote: -----

Hey all,

I'm trying to late bind a VB6 object in Component Services using c#. I've been able to do tons of late binding, but now that I have a com+ object that doesn't have a method exposed directly, I'm having tons of trouble. (lots of research, lots of newsgroups, but no success!)

I have an existing COM+ object "Company.Person" which has several interfaces. To load my object, I have to invoke a method that is "Imported" to "Person", the main interface (via the imported interface, IUser).

When late binding, this interface doesn't appear to be accessible. How do I invoke the "Load" method on IUser to populate my Company.Person object?

Attempted Code:

Type myUserType= Type.GetTypeFromProgID("Company.Person");
object objMyUser = Activator.CreateInstance(myUserType);

// parameters needed to load objMyUser
object[] parameter = new object[2];
parameter[0]=m_strDBConn;
parameter[1]="GeorgePBurdell";

//I've tried this with 8 gazillion different BindingFlags combinations....
// I haven't found any great docs on the differences between the flags
myUserType.InvokeMember("Load",
BindingFlags.Public | BindingFlags.Static |
BindingFlags.NonPublic |BindingFlags.Instance | BindingFlags.DeclaredOnly |
BindingFlags.InvokeMethod, null, objMyUser, parameter);
When I try to InvokeMember on the "Load" command, I get the dreaded mscorlib.dll error, with the extremely helpful, "unknown name" description.

Any code snippets would be great.
Thanks,
Jim
Nov 16 '05 #2

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

Similar topics

0
by: mia lanui | last post by:
I have 3 C#.NET assemblies: Assembly A: Calls methods of Assembly C, which implements an interface in Assembly B, therefore, must reference both B and C (unless late binding is used) Assembly...
5
by: Daniel Bass | last post by:
..Net is great for modulerising libraries, so that all you need do to access a DLL, is simply call Add Reference and wallah, it's as though the library were written in your project. But what...
9
by: Scott English | last post by:
I am writing an C# program. I call a method on a COM object that returns Object. I don't know the type of the object (and reflection just says its a __ComObject), but I know there is supposed to...
1
by: Jim | last post by:
Hey all I'm trying to late bind a VB6 object in Component Services using c#. I've been able to do tons of late binding, but now that I have a com+ object that doesn't have a method exposed...
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'...
5
by: CodeRazor | last post by:
How can i load an interface from a dll using System.Reflection? I can see how its possible to do this on methods, properties in a class. You create an instance of the class and use the invoke...
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...
2
by: Wonder | last post by:
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...
4
by: Rippo | last post by:
Hi I have the following console application and am attempting to late bind a class with option strict on! However of course I cant and I get the following error "Option Strict On disallows late...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.