0

I have the following solution structure:

Solution    
      \_ProjectA
      \_ProjectB (uses 3rd party DLL v1)
      \_ProjectC (uses 3rd party DLL v2)

Project A has no direct reference to the 3rd party DLL's, it just invokes methods from project B and C.

Project B and C DLL reference's properties have Specific Version set to True.

I get the following warning during build:

"No way to resolve conflict between X and Y. Choosing Y arbitrarily".

As expected, only the project using the chosen DLL works properly. How do I force those projects to use those specific versions?

Thomas Ayoub
  • 29,063
  • 15
  • 95
  • 142
pelican_george
  • 961
  • 2
  • 13
  • 33

1 Answers1

4

How do I force those projects to use those specific versions?

You can't, basically. Certainly not even close to easily. Even though Project A doesn't directly use the 3rd party DLLs, the CLR will still have to load them... at which point you've got an AppDomain with the following assemblies loaded:

  • ProjectA assembly
  • ProjectB assembly
  • ProjectC assembly
  • ThirdParty assembly, whichever version was picked

I don't think you can load multiple versions of the same assembly into the same AppDomain at a time.

Options:

  • You may be able to use separate AppDomains, one using project B and its version of the third party assembly, and one using project C and its version. In my experience, this sort of thing is very fiddly.
  • Fork the third party library (if it's open source) so you can build your own copy of it, with a different assembly name - use that for project B and let project C use the "normal" one
  • Change project B and C to use the same version

The last of these options is going to be the most maintainable by far, I suspect.

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
  • what if using simultaneously project B and C isn't a requirement. Can I load the assemblies when needed since I won't be using them in parallel? – pelican_george May 24 '16 at 07:59
  • @pelican_george: Urgh. You could potentially copy both files with separate names, and then "just in time" copy the right version in place. But this feels like a really, really brittle solution which is likely to cause a lot of pain. I still go with "the last option is likely to be the best". – Jon Skeet May 24 '16 at 08:14
  • the purpose is to launch a console application from project A and use an interface that "wraps" DLLv1 or DLLv2 to test some specific common features. The actual intent is for the user to choose which version to launch and observe some behavior. (one at a time). – pelican_george May 24 '16 at 09:01
  • @pelican_george: It's hard to tell for sure in that case, to be honest. If you could separate them out completely, I'd make project A just a new *process* launcher, and keep entirely separate copies of B and C in different directories. – Jon Skeet May 24 '16 at 09:02