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

.NET object calling by names.

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.

---
Alex Cherny
Nov 16 '05 #1
4 1160
Take a look at the Reflection namespace.

"Alexander Cherny" <bl***@gainskeeper.com> wrote in message
news:e6**************@tk2msftngp13.phx.gbl...
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.

---
Alex Cherny

Nov 16 '05 #2
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

"Alexander Cherny" <bl***@gainskeeper.com> дÈëÏûÏ¢
news:e6**************@tk2msftngp13.phx.gbl...
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.

---
Alex Cherny

Nov 16 '05 #3
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
"Xia Wei" <ip*****@gmail.com> escribió en el mensaje
news:d0***********@mail.cn99.com...
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

Nov 16 '05 #4
thanks, guys. everything's working great!

---
Alex Cherny
Nov 16 '05 #5

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

Similar topics

2
by: Midas | last post by:
Greetings everyone, I'm including code, for cut/paste, to better explain my question. I create a Car object then I call some of its methods. No problem. Then I try to pass, to a function, the name...
18
by: Steven Bethard | last post by:
In the "empty classes as c structs?" thread, we've been talking in some detail about my proposed "generic objects" PEP. Based on a number of suggestions, I'm thinking more and more that instead of...
22
by: Peter Ammon | last post by:
A friend was asked "How many ways are there to create an object in C++?" in an interview. Apparently, the "right" answer was eleven. Does anyone know how the interviewer arrived at that number? ...
6
by: Luke | last post by:
Here is my emails to Danny Goodman (but probably he is very busy so he didn't answered it). First email(simple): Subject: JavaScript Arrays " We all know the array can act like HashMap, but is...
5
by: KenK | last post by:
Hi all, Been reading all day about object serialization techniques in C# and my problem is that everything I read is requiring a "known" object class. Is there a way to create an object from...
6
by: Murray Hopkins | last post by:
Hi. THE QUESTION: How do I get a reference to my Object when processing an event handler bound to an html element ? CONTEXT: Sorry if it is a bit long. I am developing a JS calendar tool....
5
by: taumuon | last post by:
I've got an object, Person, that supports IEquatable<Person>. It implements bool Equals(Person obj) as well as overriding bool Equals(object obj) I've got a container type that holds a member...
20
by: raylopez99 | last post by:
Inspired by Chapter 8 of Albahari's excellent C#3.0 in a Nutshell (this book is amazing, you must get it if you have to buy but one C# book) as well as Appendix A of Jon Skeet's book, I am going...
275
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
0
by: John O'Hagan | last post by:
Here's a strange one for you: I have a generator function which produces lists of numbers and takes options which influence the output. The generator contains a loop, and to enable the options...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.