Click here to Skip to main content
15,912,977 members
Home / Discussions / C#
   

C#

 
GeneralRe: Socket Programming Pin
Colin Angus Mackay29-Mar-07 21:06
Colin Angus Mackay29-Mar-07 21:06 
GeneralRe: Socket Programming Pin
Sendilkumar.M30-Mar-07 1:39
Sendilkumar.M30-Mar-07 1:39 
GeneralRe: Socket Programming Pin
Sendilkumar.M30-Mar-07 1:41
Sendilkumar.M30-Mar-07 1:41 
QuestionMerging C++ and C# Pin
vivram29-Mar-07 18:07
vivram29-Mar-07 18:07 
AnswerRe: Merging C++ and C# Pin
N a v a n e e t h29-Mar-07 18:12
N a v a n e e t h29-Mar-07 18:12 
GeneralRe: Merging C++ and C# Pin
vivram29-Mar-07 18:33
vivram29-Mar-07 18:33 
QuestionWindow Z-order Pin
gauntalus29-Mar-07 17:44
gauntalus29-Mar-07 17:44 
QuestionHow can I check if a string is numeric before actually converting it to a number? [modified] Pin
cateyes9929-Mar-07 17:03
cateyes9929-Mar-07 17:03 
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 

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.