Click here to Skip to main content
15,888,579 members
Home / Discussions / C#
   

C#

 
AnswerRe: Can I check if a string is numeric before actually converting it? Pin
Christian Graus29-Mar-07 17:13
protectorChristian Graus29-Mar-07 17:13 
GeneralRe: Can I check if a string is numeric before actually converting it? Pin
cateyes9929-Mar-07 17:41
cateyes9929-Mar-07 17:41 
GeneralRe: Can I check if a string is numeric before actually converting it? Pin
mav.northwind29-Mar-07 19:15
mav.northwind29-Mar-07 19:15 
GeneralRe: Can I check if a string is numeric before actually converting it? Pin
cateyes9929-Mar-07 19:41
cateyes9929-Mar-07 19:41 
GeneralRe: Can I check if a string is numeric before actually converting it? Pin
Martin#29-Mar-07 19:46
Martin#29-Mar-07 19:46 
GeneralRe: Can I check if a string is numeric before actually converting it? Pin
cateyes994-Oct-07 16:15
cateyes994-Oct-07 16:15 
QuestionLoading custom controls from dll dynamically at runtime? Pin
irrdev29-Mar-07 16:16
irrdev29-Mar-07 16:16 
AnswerRe: Loading custom controls from dll dynamically at runtime? Pin
Patrick Etc.29-Mar-07 20:48
Patrick Etc.29-Mar-07 20:48 
Well, as you might imagine, the only way to do this is to use Reflection, since Reflection is the namespace that knows about assemblies.

So, here's a really simple snippet. Create a windows project and double click to get the Form Load event. Add a using directive for System.Reflection. Here's my code for the form load event.

private void Form1_Load(object sender, EventArgs e)
{
    OpenFileDialog dlg = new OpenFileDialog();
    List<Control> loadedCtrls = new List<Control>();

    if (dlg.ShowDialog() == DialogResult.OK)
    {
        Assembly src = Assembly.LoadFile(dlg.FileName);

        Type[] types = src.GetExportedTypes();
        foreach (Type test in types)
        {
            // First test that the type is a class and that it's not an abstract class,
            // and finally that it is either Control or a subtype of Control.
            if (test.IsClass && !test.IsAbstract && typeof(Control).IsAssignableFrom(test))
            {
                // Now make sure we have an empty public constructor for
                // the CreateInstance method.
                if (test.GetConstructor(Type.EmptyTypes) != null)
                    loadedCtrls.Add((Control)src.CreateInstance(test.FullName));
            }
        }
    }

    Console.WriteLine(loadedCtrls.Count.ToString());
}


Using this snippet on System.Windows.Forms.dll, I get 57 publically constructable Controls. I think this is pretty much what you're looking for.
QuestionGraphics... Pin
max2929729-Mar-07 14:06
max2929729-Mar-07 14:06 
AnswerRe: Graphics... Pin
Vasudevan Deepak Kumar29-Mar-07 14:09
Vasudevan Deepak Kumar29-Mar-07 14:09 
AnswerRe: Graphics... Pin
Christian Graus29-Mar-07 15:30
protectorChristian Graus29-Mar-07 15:30 
QuestionFiles Pin
max2929729-Mar-07 14:03
max2929729-Mar-07 14:03 
AnswerRe: Files Pin
Vasudevan Deepak Kumar29-Mar-07 14:10
Vasudevan Deepak Kumar29-Mar-07 14:10 
AnswerRe: Files Pin
blackjack215029-Mar-07 23:33
blackjack215029-Mar-07 23:33 
QuestionAccessing MDI parent controls through child forms, Pin
Neo_Shehpar29-Mar-07 13:46
Neo_Shehpar29-Mar-07 13:46 
AnswerRe: Accessing MDI parent controls through child forms, [modified] Pin
Tirthadip29-Mar-07 19:29
Tirthadip29-Mar-07 19:29 
QuestionProgramatically exploring COM/ActivX methods/properties in C# Pin
Michael Elly29-Mar-07 11:04
Michael Elly29-Mar-07 11:04 
Question2 port tcplistener? Pin
dino209429-Mar-07 11:03
dino209429-Mar-07 11:03 
AnswerRe: 2 port tcplistener? Pin
Colin Angus Mackay29-Mar-07 22:58
Colin Angus Mackay29-Mar-07 22:58 
QuestionMake a strongly typed dataset COM accesible Pin
Brent Lamborn29-Mar-07 10:32
Brent Lamborn29-Mar-07 10:32 
QuestionTesting whether class 1 implements an interface found in class 2 Pin
Marc Clifton29-Mar-07 10:11
mvaMarc Clifton29-Mar-07 10:11 
AnswerRe: Testing whether class 1 implements an interface found in class 2 Pin
dbrenth29-Mar-07 10:29
dbrenth29-Mar-07 10:29 
AnswerRe: Testing whether class 1 implements an interface found in class 2 Pin
Pete O'Hanlon29-Mar-07 10:33
mvePete O'Hanlon29-Mar-07 10:33 
GeneralRe: Testing whether class 1 implements an interface found in class 2 Pin
Marc Clifton29-Mar-07 11:15
mvaMarc Clifton29-Mar-07 11:15 
GeneralRe: Testing whether class 1 implements an interface found in class 2 Pin
Scott Dorman29-Mar-07 20:55
professionalScott Dorman29-Mar-07 20:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.