.NET object calling by names.

  • Thread starter Thread starter Alexander Cherny
  • Start date Start date
A

Alexander Cherny

it's possible to call COM-object methods by their names, using
CoCreateInstance(), QueryInterface(), GetIDsOfNames(), etc.

is there any chance to call .NET object the same way - by name of an object,
a method, a parameter?

thank you.
 
it's possible to invoke a method by the method's name and the parameter
list - through System.Reflection.MethodInfo class.
but i think there is no way to get a object by it's name. once the code is
compiled, the object's name is nothing.

- Xia Wei
 
Objects (instances) have no name, but classes (and types in general) have
names and you can create objects (instances) by name using the
System.Activator.CreateInstanceXXX(...), equivalent to the classic VB
CreateObject function.

Once the object is created, you can invoke methods by name using
System.Type.InvokeMember("mymethodname",..., myobject,...)

--

Carlos J. Quintero

MZ-Tools 4.0: Productivity add-ins for Visual Studio .NET
You can code, design and document much faster.
http://www.mztools.com
 
Back
Top