Home All Groups Group Topic Archive Search About

Files in an application?

Author
16 May 2006 9:31 PM
Dave
How can my executable determine the classes (specifically User Controls) in
itself? My program needs to know the list of User Controls that are in it.

Author
16 May 2006 9:39 PM
Herfried K. Wagner [MVP]
"Dave" <D***@discussions.microsoft.com> schrieb:
> How can my executable determine the classes (specifically User Controls)
> in
> itself? My program needs to know the list of User Controls that are in it.

'[Assembly].GetExecutingAssembly.GetTypes' will return an array of types
defined in the assembly.  Then you can check each 'Type' object's 'BaseType'
property and compare it to the 'UserControl' type.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
17 May 2006 3:58 PM
Dave
That's what I need, except I want to use the info to instantiate my User
Control. I want to put your suggested code in a function and return the User
Control back to the calling routine. This function returns Types, and I can't
seem to convert the Type returned to a User Control.

Any ideas how to do that?
Thanks for all your help.

Show quoteHide quote
"Herfried K. Wagner [MVP]" wrote:

> "Dave" <D***@discussions.microsoft.com> schrieb:
> > How can my executable determine the classes (specifically User Controls)
> > in
> > itself? My program needs to know the list of User Controls that are in it.
>
> '[Assembly].GetExecutingAssembly.GetTypes' will return an array of types
> defined in the assembly.  Then you can check each 'Type' object's 'BaseType'
> property and compare it to the 'UserControl' type.
>
> --
>  M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
>  V B   <URL:http://classicvb.org/petition/>
>
>