Return a list of types in the assembly: Assembly.GetExecutingAssembly().GetTypes()
Test if a type implements an interface if( typeof(IYourInterface).IsAssignableFrom(type) ) { Create an instance: Activator.CreateInstance( type, new object[] { any, parameters, the, ctor, needs } ) Adam.. > -----Original Message----- > From: Unmoderated discussion of advanced .NET topics. > [mailto:[EMAIL PROTECTED] On Behalf Of David Rutten > Sent: Wednesday, June 22, 2005 7:27 AM > To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM > Subject: [ADVANCED-DOTNET] Searching classes in an assembly > > Hello all, > > I've been wondering how to do something tricky, and I > can'tfind a single reference about it in the msdn docs... > > 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 > 2) create an instance of a class using a variable type (or don't I?) > > Any thoughts on how to approach this? =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com