Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Property Grid
Message
From
27/04/2004 10:30:56
 
 
To
27/04/2004 09:45:44
General information
Forum:
ASP.NET
Category:
Other
Title:
Miscellaneous
Thread ID:
00898494
Message ID:
00898526
Views:
18
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform