Introduction:
In this article,i am going to explain about how to call a dll method’s without adding the dll refrence in asp.net project.
Main:
In Above 2.0 framework’s we have a option called “Assembly.LoadFrom” helps to load dll files programatically,
See this below simple examble
Assembly assembly = Assembly.LoadFrom(@"C:\Documents and Settings\Sample.dll");
Type local_type = assembly.GetType("GetString"); //Getting Class File Name
Object local_Instance = Activator.CreateInstance(local_type);
string local_string = (string)local_type.InvokeMember("ReturnString", BindingFlags.InvokeMethod, null, local_Instance);
//Just invoking returnstring method,If you are calling any parameterised methods,add params at last parameter here,
Response.Write(local_string);
Assembly assembly = Assembly.LoadFrom(@"C:\Documents and Settings\Sample.dll"); Type local_type = assembly.GetType("GetString"); //Getting Class File Name Object local_Instance = Activator.CreateInstance(local_type); string local_string = (string)local_type.InvokeMember("ReturnString", BindingFlags.InvokeMethod, null, local_Instance); //Just invoking returnstring method,If you are calling any parameterised methods,add params at last parameter here, Response.Write(local_string); |
Conclusion:
Hope this helps,
Happy Coding.