Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Property Grid
Message
De
27/04/2004 10:30:56
 
 
À
27/04/2004 09:45:44
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Divers
Thread ID:
00898494
Message ID:
00898526
Vues:
19
Wilson,

>Is there a way to instanciate a class from a string.

Yes, you need to use reflection. Here's an example:
string DLLName = "MyDLL";
string ClassName = "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);
Sorry it's in C# instead of VB, but you can go to either
http://authors.aspalliance.com/aldotnet/examples/translate.aspx
or
http://www.kamalpatel.net/ConvertCSharp2VB.aspx
to convert it to VB.

~~Bonnie
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform