dll library loading
-
There may be some instances that I would load the dll library. One time that I might be using this abc.dll then later in time that I would have the application to change to different dll which would be xyz.dll. Basically that they have the methods but have very different algorithms inside there. What's the best way for me to do that? Right now that I'm using this:
Assembly a = Assembly.LoadFrom("abc.dll"); Type mm = a.GetType("abc"); object o = Activator.CreateInstance(mm); object[] par = new object[] { }; ds_LUT = (DataSet)(mm.InvokeMember("GetLutTable", BindingFlags.Default | BindingFlags.InvokeMethod, null, o, par)); Is there a way to keep the dll open until I am "finished" with it so I can close it and open the other dll? That will be done during runtime. Additional note: The dll are in c# language and was created in Visual Studio.Net 2005 software.
-
There may be some instances that I would load the dll library. One time that I might be using this abc.dll then later in time that I would have the application to change to different dll which would be xyz.dll. Basically that they have the methods but have very different algorithms inside there. What's the best way for me to do that? Right now that I'm using this:
Assembly a = Assembly.LoadFrom("abc.dll"); Type mm = a.GetType("abc"); object o = Activator.CreateInstance(mm); object[] par = new object[] { }; ds_LUT = (DataSet)(mm.InvokeMember("GetLutTable", BindingFlags.Default | BindingFlags.InvokeMethod, null, o, par)); Is there a way to keep the dll open until I am "finished" with it so I can close it and open the other dll? That will be done during runtime. Additional note: The dll are in c# language and was created in Visual Studio.Net 2005 software.
Without getting into additional app domains, once the DLL is loaded you will not be able to unload it. You can load more than one DLL at a time, so the idea of needing to "close it and open the other dll" doesn't really apply.
Scott.
—In just two days, tomorrow will be yesterday. [Forum Guidelines] [Articles] [Blog]
-
There may be some instances that I would load the dll library. One time that I might be using this abc.dll then later in time that I would have the application to change to different dll which would be xyz.dll. Basically that they have the methods but have very different algorithms inside there. What's the best way for me to do that? Right now that I'm using this:
Assembly a = Assembly.LoadFrom("abc.dll"); Type mm = a.GetType("abc"); object o = Activator.CreateInstance(mm); object[] par = new object[] { }; ds_LUT = (DataSet)(mm.InvokeMember("GetLutTable", BindingFlags.Default | BindingFlags.InvokeMethod, null, o, par)); Is there a way to keep the dll open until I am "finished" with it so I can close it and open the other dll? That will be done during runtime. Additional note: The dll are in c# language and was created in Visual Studio.Net 2005 software.
The only way to do this would be to have the DLL loaded into a separate AppDomain, which you could then unload. Mind you, I don't see what benefit this would bring you, as the Type would be completely different when you load up the new DLL - even if they have the same name, they really are different types so you won't have to worry about implementation collisions.
Deja View - the feeling that you've seen this post before.
-
There may be some instances that I would load the dll library. One time that I might be using this abc.dll then later in time that I would have the application to change to different dll which would be xyz.dll. Basically that they have the methods but have very different algorithms inside there. What's the best way for me to do that? Right now that I'm using this:
Assembly a = Assembly.LoadFrom("abc.dll"); Type mm = a.GetType("abc"); object o = Activator.CreateInstance(mm); object[] par = new object[] { }; ds_LUT = (DataSet)(mm.InvokeMember("GetLutTable", BindingFlags.Default | BindingFlags.InvokeMethod, null, o, par)); Is there a way to keep the dll open until I am "finished" with it so I can close it and open the other dll? That will be done during runtime. Additional note: The dll are in c# language and was created in Visual Studio.Net 2005 software.
How about letting the types within the assemblies inherit a given interface? Then cast the instances to the interface on creation and the methods will be the same, but the implementation in the various types will differ. -Larantz-
for those about to code, we salute you
http://www.itverket.noPlease refer to the Forum Guidelines for appropriate posting.