this is the code strip
Assembly m_oAssembly = Assembly.LoadFr om(assemblySour ce);
Type m_oTypeClass = m_oAssembly.Get Type(classname, false);
MethodInfo m_oMethodInfoRe questInitialize =
m_oTypeClass.Ge tMethod("Initia lize",System.Re flection.Bindin gFlags.Public
|System.Reflect ion.BindingFlag s.Instance);
object m_oClassInstanc e = Activator.Creat eInstance(m_oTy peClass);
m_oMethodInfoRe questInitialize .Invoke(m_oClas sInstance,m_oRe questArguments) ;
Thanks in advance
Raj
--
Try it for free:
http://www.sharpVoice.com
"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
CKR Rajesh <_r************ @usa.net> wrote: I have 2 dlls on which i have the same class MyClass defined. Say A.dll
and B.dll
The classes have a function (but different functionality)
void f();
I use .Net late binding using Activator.Creat eInstanceFrom method to
dynamically call the method f() in either dll.
But I see that once i successfully call the f() method of either of the
dll, I am not able to call the f() method in the other dll even if
I pass the other dll's name as the parameter to CreateInstanceF rom
method. Always f() from the dll which got executed first is always getting
executed...
Am i missing something?
Rather than passing the other DLL's name, try using Assembly.GetTyp e on
the appropriate loaded assembly, and then creating an instance using
Activator.Creat eInstance passing in the actual type.
--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too