Here is some code for making an instance of a class from a string:
AppDomain.CurrentDomain.CreateInstanceAndUnwrap("thenameofsomeassembly", "thenameofsomeclass")
This call will return that class typed as Object, so you'll need to cast it to use the members of your class.
So, if you have a dll called MyDll.dll, and a class in it called MyClass you could do something like
(In VB)
Dim myClassInstance as MyClass
myClassInstance = directcast(AppDomain.CurrentDomain.CreateInstanceAndUnwrap("MyDll", "MyClass"), MyClass)
myClassInstance.SomeMethod(parm1)
In order for this to work right you will need to add a reference to MyDll.dll to your project. There are ways to get around that if you have to, but that's the easiest.
Also keep in mind, that if the class is under a namespace, you'll need to use that namespace in the second parameter.
Does that cover what you're looking for or was I off base
Thanks.
|