Loading Dlls programatically in C#
-
Hey guys, I need to be able to figure out (based on users selection from the UI) which class library project to use. In other words, there is a mthod lets say initialize or something that would be receiving some parameters from the User (such as the name of the class library project and it's type, however the name is enough to have some sort of a if else block and load the right project. Well actually I wanna be careful here, it's not really loading the class library project from here, it's more like using the correct project for all the subsequent method calls from this project (as the class library projects may or maynot be different from each other in terms of the methods they define. So I need to be able to point this project, which also happens to be a Class library project to the correct version of the subsequent project based on the name of the project that is provided by the user from the UI text box. I'm sure whats the ideal solution here, I think I should just add a reference dynamically based on the project name coming in....in other words do some sort of string comparison adn based on that add a reference to the right Class library project adn then it will point to it. can someone please help me with this, if you think this isn't what needs to happen, or if it is the right approach, any feedback would be highly appreciated? Thanks Tina
-
Hey guys, I need to be able to figure out (based on users selection from the UI) which class library project to use. In other words, there is a mthod lets say initialize or something that would be receiving some parameters from the User (such as the name of the class library project and it's type, however the name is enough to have some sort of a if else block and load the right project. Well actually I wanna be careful here, it's not really loading the class library project from here, it's more like using the correct project for all the subsequent method calls from this project (as the class library projects may or maynot be different from each other in terms of the methods they define. So I need to be able to point this project, which also happens to be a Class library project to the correct version of the subsequent project based on the name of the project that is provided by the user from the UI text box. I'm sure whats the ideal solution here, I think I should just add a reference dynamically based on the project name coming in....in other words do some sort of string comparison adn based on that add a reference to the right Class library project adn then it will point to it. can someone please help me with this, if you think this isn't what needs to happen, or if it is the right approach, any feedback would be highly appreciated? Thanks Tina
Hi, I think you might need to look for Reflection to achieve this.
himanshu
-
Hey guys, I need to be able to figure out (based on users selection from the UI) which class library project to use. In other words, there is a mthod lets say initialize or something that would be receiving some parameters from the User (such as the name of the class library project and it's type, however the name is enough to have some sort of a if else block and load the right project. Well actually I wanna be careful here, it's not really loading the class library project from here, it's more like using the correct project for all the subsequent method calls from this project (as the class library projects may or maynot be different from each other in terms of the methods they define. So I need to be able to point this project, which also happens to be a Class library project to the correct version of the subsequent project based on the name of the project that is provided by the user from the UI text box. I'm sure whats the ideal solution here, I think I should just add a reference dynamically based on the project name coming in....in other words do some sort of string comparison adn based on that add a reference to the right Class library project adn then it will point to it. can someone please help me with this, if you think this isn't what needs to happen, or if it is the right approach, any feedback would be highly appreciated? Thanks Tina
Hi Tina, I would suggest you to go with a event subscription based model to achieve this. Please see Observer Pattern for details. Make one project for Subject & Define all the other dll projects as observers. Let me know if you want to see a working code of it. Regards, Rahul Shukla