471,328 Members | 1,865 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Newbie qustion about InvokeMember


I'm not new to C# but I am new to the concept of calling a member
using Interop.

I can access 1 function and properties in an external dll no
problem....but I can't understand how I'm supposed to do something
which in VB seems simple by comparison.

I need to query a property on an object, that property should return a
pointer to an object of a different type.

In this case, I connect to "AppManager" and ask "AppManager" for a
pointer to its "Machines" Object.

I can successfully get Appmanager to return things like its version or
other public Fields, but I can't get it to return what I want.

Here is the code.

Type tAppMgr =
object oAppMgr =
null, oAppMgr,
new object[] { "CALNTMGT501", "QDB", @"removed",
"removed" });

object oVersion = tAppMgr.InvokeMember("Version",
BindingFlags.GetProperty, null, oAppMgr, null);

Debug.WriteLine(((string)oVersion)); // This

// In this below; oMachines stays "null"...ie nothing
is returned.

object oMachines = tAppMgr.InvokeMember( //
BindingFlags.GetProperty | BindingFlags.GetField |
, null, oAppMgr, null);

Type tMachines = oMachines.GetType();
object count = tMachines.InvokeMember("Count",
BindingFlags.GetField, null, oMachines, null);

catch (Exception e)
As equivalent call in VB would be something like

oMachines = oAppMgr.Machines

Any help appreciated!

Aug 12 '08 #1
0 935

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Jared Hagel | last post: by
reply views Thread by Alex Zhitlenok | last post: by
1 post views Thread by Rein Petersen | last post: by
reply views Thread by Pat Ireland | last post: by
3 posts views Thread by Patrick Ireland | last post: by
4 posts views Thread by Howard Kaikow | 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.