Thank you Bogdan, this is exactly what I needed to know.
Appearantly I have been looking in all the wrong places. Maybe I should read
something on how to search the msdn :)   It took me well over 15 minutes to
find the ASCII tables yesterday as well...

David





----- Original Message -----
From: "Bogdan Lachendro" <[EMAIL PROTECTED]>
To: <ADVANCED-DOTNET@DISCUSS.DEVELOP.COM>
Sent: Wednesday, June 22, 2005 2:59 PM
Subject: Re: [ADVANCED-DOTNET] Searching classes in an assembly


On 2005-06-22 14:26, David Rutten wrote:
Hello all,

I've been wondering how to do something tricky, and I can'tfind a single
reference about it in the msdn docs...

Strange....

Imagine I have a regular windows program, with a bunchof classes that all
implement a certain interface. There are also lots of other classes that
do
not implement it.
The interface defines a readonly property called Name which returns the
name of the class.
Now I would like add a textbox, where the user can type a string at
runtime, and then the app has to find (and initialize) the class which
name
equals the entered text.

But for this to work I need to do 2 things I can't find:
1) search an assembly at runtimefor classes that implement an interface
See the System.Reflection.Assembly.GetTypes(...)
And System.Type.GetInterfaces()

2) create an instance of a class using a variable type (or don't I?)

See System.Activator.CreateInstance(...)

Regards,
Bogdan

===================================
This list is hosted by DevelopMentorŽ  http://www.develop.com

View archives and manage your subscription(s) at
http://discuss.develop.com



===================================
This list is hosted by DevelopMentorŽ  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to