1

This question, does not answer my question.

I am referencing 2 dll's of the same application but 2 different versions . As I'm calling similar functions from both the dll's some of my code is getting repeated (currently I'm using base class and inheriting common functions but I'm not happy with that approach as it is not a DRY code).

I believe this can be solved if I can reference only one of the dll's during run time.

My application has the option to choose which version of that software to open, depending upon the version the user chooses.

One approach I could think was, The application should reference dll of that version, which the user chooses from the radio button, but I do not know how to do this, has someone done something like this before?

Sample code when using dll of earlier version

using ABC = ABC2015;

 protected static string ABC_APP_PATH = System.IO.Path.Combine(Environment.GetEnvironmentVariable("PROGRAMFILES"), "ABC", "ABC 2015", "ABC.exe");

Sample code when using dll of current version

using ABC = ABC2016;

 protected static string ABC_APP_PATH = System.IO.Path.Combine(Environment.GetEnvironmentVariable("PROGRAMFILES"), "ABC", "ABC 2016", "ABC.exe");

As we see in the example above, the code is written in 2 different files and same line is repeated, there are more such instances. if I can use conditinoal referencing, I believe, I can solve this issue.

Community
  • 1
  • 1
vin
  • 869
  • 4
  • 17
  • 33

1 Answers1

3

There is an MSDN blog link which i guess is similar to what you are seeking

https://blogs.msdn.microsoft.com/abhinaba/2005/11/30/c-2-0-using-different-versions-of-the-same-dll-in-one-application/

abhi
  • 1,059
  • 9
  • 19
  • Thanks, this answer was useful, it got me really close to what I was looking for, but I had to do few more changes to fully solve that, I will soon share my answer with all the things that I applied. Without your help, I could not have got there, thanks a ton! – vin Dec 28 '16 at 12:54
  • great it helped, Do share your answer so that it can be useful for others – abhi Dec 29 '16 at 12:06