Hi,
Originally I had:
IModule objModule =
ModuleManager.GetInstance(@"C:\projects\bin\librar y\Module.dll");
Type objType = objModule.GetType();
MethodInfo objMethodInfo = objType.GetMethod("GetString");
Thread objThread = new Thread(objMethodInfo);
but that doesn't work because the Thread Constructor is expecting a method
rather than an object (in this case MethodInfo). Even using:
IModule objModule =
ModuleManager.GetInstance(@"C:\projects\bin\librar y\Module.dll");
Type objType = objModule.GetType();
MethodInfo objMethodInfo = objType.GetMethod("GetString");
ThreadStart objThreadStart= new (objMethodInfo)
Thread objThread = new Thread(objThreadStart);
won't work because [yet again] ThreadStart Constructur expecting a method
rather than an object.
Thanks in Advance.
Regards,
Ahmad
"Jon Skeet [C# MVP]" wrote:
On Jul 10, 2:28 pm, Ahmad <Ah...@discussions.microsoft.comwrote:
Is it possible to do something like the the following:
IBaseClass objClass = new LoadClassFromDLL( "Module.DLL");
ThreadStart objThreadStart= new
(objClass.GetFunctionFromName("GetString"))
Thread objThread = new Thread (objThreadStart)
objThread.Start();
bearing in mind the function 'GetFunctionFromName' doesn't actually exist,
and I don't know how to implement it (I've sorted out the 'LoadClassFromDLL'
function).
Yes, that's basically possible. Look at Type.GetMethod and
MethodInfo.Invoke. If you're still stuck after a bit of looking, let
me know and I'll write up a short example program. (I'd do it now, but
I really ought to get on with some work...)
Jon