Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using Reflection
Message
De
14/01/2009 20:29:57
 
 
À
20/12/2008 11:28:59
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
C# 3.0
OS:
Vista
Application:
Desktop
Divers
Thread ID:
01368964
Message ID:
01373852
Vues:
17
Works great. Thanks muchhhhhhh!!!!!

bob


>Hi Bob,
>
>Here's a little blurb I frequently use to show how to do this:
>
>Code to instantiate a class with reflection:
>
>
>string DLLName = "MyDLL.dll";
>string ClassName = "MyDll.MyClass";
>System.Reflection.Assembly oDLL;
>object oClass;
>
>// This "loads" the .DLL
>oDLL = System.Reflection.Assembly.LoadFrom(DLLName);
>
>// This creates the class instance
>oClass = oDLL.CreateInstance(ClassName, true);
>
>And if you need to pass parameters
>
>// Create an object array to pass your parameters
>object [] args = new object[1];
>args[0] = MyKey;
>oForm = (Form)oDLL.CreateInstance(classname, true, System.Reflection.BindingFlags.CreateInstance, null, args, null, null);
>
>
>The only thing you'll need to change in the above sample, is that the DLLName will also include the path to the DLL. That should be all you need to do. (error trapping is recommended of course <g>)
>
>~~Bonnie
>
>
>
>>Can anyone point me in the right direction (sample code, etc.) to do the following:
>>
>>I need to invoke a class at runtime (most likely via reflection) contained in a DLL that I don't know until runtime its location. It will not be located in the start-in folder or program folder.
>>
>>Thanks!!
>>
>>Bob
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform