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

Newbie qustion about InvokeMember

All,

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.

try
{
Type tAppMgr =
Type.GetTypeFromProgID("NetIQOLE.AppManager");
object oAppMgr =
System.Activator.CreateInstance(tAppMgr);
tAppMgr.InvokeMember(
"Logon",
BindingFlags.InvokeMethod,
null, oAppMgr,
new object[] { "CALNTMGT501", "QDB", @"removed",
"removed" });

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

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

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

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

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

Debug.WriteLine(count.ToString());
}
catch (Exception e)
{
Debug.WriteLine(e.InnerException.Message);
}
As equivalent call in VB would be something like

oMachines = oAppMgr.Machines

Any help appreciated!

Cliff.
Aug 12 '08 #1
0 1049

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

Similar topics

0
by: Jared Hagel | last post by:
I can't use Type.InvokeMember(...) on a remote object. But when I use Type.InvokeMember(...) on a non-remote object in the exact same way, I don't have a problem. Does someone know what I'm...
0
by: Alex Zhitlenok | last post by:
Hi, On Google, one can find a lot of statements that Invoke and InvokeMemeber work alike. However, my own experience contradicts this statement. 1. Surprisingly, Invoke and InvokeMember methods...
1
by: Rein Petersen | last post by:
Hi All, I'm invoking Type.InvokeMember() on a COM class (via COMInterop) through a generalized interface. However, each specialized instance (of the COMInterop generic interface) requires...
0
by: Pat Ireland | last post by:
I continue to investigate issues with making explicit InvokeMember calls (necessary when dynamically loading classes). My quest lets me use a simple class to invoke another class's member method...
3
by: Patrick Ireland | last post by:
I am dynamically loading a class. One of the methods of the class takes a short * (by reference) argument. However, the InvokeMember call used to invoke the method of the class passings arguments...
3
by: Pat Ireland | last post by:
The following code shows what I am trying to do. The normal invocation of the CalcByRef produces the correct results, however, using the InvokeMember fails to correctly pass the single argument by...
4
by: Howard Kaikow | last post by:
I am trying to retrive some WMI properties using Option Strict On. This requires the use of InvokeMember. I know that there are alternative ways to get the values, but I want to learn how to...
1
by: tommyk | last post by:
I am writing a small program that reads a text file filled with a large number of IP addresses and attempts to add them to IIS so that they will be blocked. For some reason, about one in every...
4
by: adiel_g | last post by:
I am trying to set a value on a structure object dynamically using InvokeMember. After I call InvokeMember, the value on the Admin flag does not get updated. Here is the following sample code to...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
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
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...

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.