Is it possible to add import dll during runtime?
-
Hi all, I do have lots of dlls saved in one folder and the new dll will be added to the same folder frequetly. I also have a program, myProgram, that needs to reference all dlls in that folder. Inorder to use the functions/methods of a dll, we have to 1) add Reference to myProgram, 2) using mydll; 3) create the instance and call the appropriate function. So how can I add the reference and import the dlls as the program click on Button so I can use functions from those dlls. or is there any other ways that myProgram to find out if there is new dll in the folder and start using it without recompliing myProgram.
-
Hi all, I do have lots of dlls saved in one folder and the new dll will be added to the same folder frequetly. I also have a program, myProgram, that needs to reference all dlls in that folder. Inorder to use the functions/methods of a dll, we have to 1) add Reference to myProgram, 2) using mydll; 3) create the instance and call the appropriate function. So how can I add the reference and import the dlls as the program click on Button so I can use functions from those dlls. or is there any other ways that myProgram to find out if there is new dll in the folder and start using it without recompliing myProgram.
Hi, if your source code is referring to managed code that resides in some DLL, then you need to add a reference, and you may choose to (or not to) use a using statement, in order to tell the compiler how to find the types you are using. if on the other hand you want to use types from some DLL files using reflection only, then no reference and no using statement is needed pointing to these DLL files; with the right code you can discover and use any managed DLL you can reach. Look for "reflection" on CodeProject or Google. :)
Luc Pattyn [Forum Guidelines] [My Articles]
Voting for dummies? No thanks. X|
-
Hi all, I do have lots of dlls saved in one folder and the new dll will be added to the same folder frequetly. I also have a program, myProgram, that needs to reference all dlls in that folder. Inorder to use the functions/methods of a dll, we have to 1) add Reference to myProgram, 2) using mydll; 3) create the instance and call the appropriate function. So how can I add the reference and import the dlls as the program click on Button so I can use functions from those dlls. or is there any other ways that myProgram to find out if there is new dll in the folder and start using it without recompliing myProgram.
-
Hi all, I do have lots of dlls saved in one folder and the new dll will be added to the same folder frequetly. I also have a program, myProgram, that needs to reference all dlls in that folder. Inorder to use the functions/methods of a dll, we have to 1) add Reference to myProgram, 2) using mydll; 3) create the instance and call the appropriate function. So how can I add the reference and import the dlls as the program click on Button so I can use functions from those dlls. or is there any other ways that myProgram to find out if there is new dll in the folder and start using it without recompliing myProgram.
Yes, as when using add-ins. I've done a few. 1 + 2) Those concepts don't apply to runtime, only to development and compile time. Your app can browse the directory for DLLs, load the assemblies they contain, and it can then instantiate and use the classes therein. But it has to know what sorts of things it can do with the classes. For doing add-ins, I define an Interface (or abstract class) that the app knows about. After the app loads the assembly it browses the classes contained and instantiates any it finds that implement the Interface. See System.Reflection.Assembly