If you want to add a dll at run time and use its methods, then you have to use dynamic loading technique already available in C#.
Namespaces:
using System.Reflection;
using System.IO;
code:
public void myDllStuff(string myDll)
{
string dllName = myDll;
Assemly asm = null;
try{
asm = Assembly.Load(asmName);
Type[] types = asm.GetTypes();
noArgumentMethod(asm, "myDll.myMethod");
withArgumentMethod(asm, "myDll.myArgumentMethod", true, 1);
}
catch
{
}
}
public void noArgumentMethod(string asm, string methodName)
{
Type myMethod = asm.GetType(methodName);
object obj = Activator.CreateInstance(myMethod);
MethodInfo mi = myMethod.GetMethod(methodName);
mi.Invoke(obj, null);
}
public void withArgumentMetho(string asm, string methodName, bool argument1, int argument2)
{
Type myArgumentMethod = asm.GetType(methodName);
object obj = Activator.CreateInstance(myArgumentMethod);
MethodInfo mi = myArgumentMethod("myArgumentMethod");
mi.Invoke(obj, new object[]{argument1, argument2});
}
You said that you want this whole process to run only for one time, you can do this by setting a flag or saving to a file or database on server.
Hope it helps..