Hi,
I have a project A (an application) which includes a package B, which in turn contains a third party package C3, which in turn contains another third party package package D3. Both packages A and D3 use the same third party package NLog but with different versions: package A includes NLog with version 5.0.0, and package D3 contains NLog with lower version 4.5.0.
A (application)
|-B
|...|-C3
|.......|-D3
|...........|-NLog 4.5.0
|
|-NLog 5.0.0
Compilation of project A is ok and execution of a certain program P is ok.
Then I have a test (MSTest) project T that includes project A:
T (test project)
|-A (application)
....|-B
....|...|-C3
....|.......|-D3
....|...........|-NLog 4.5.0
....|
....|-NLog 5.0.0
But, although project T compiles correctly, package D3 throws an exception at runtime when running a test which internally loads program P with message:
System.TypeLoadException: 'Could not load type 'NLog.Targets.OutputDebugStringTarget' from assembly 'NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c'.'
Since project A runs ok, and project T is just a test project which includes project A, I would expect both executions to behave the same but it seems that, when executing the test in project T, D3 uses NLog 5.0.0 and fails because it expects 4.5.0.
The Global Assembly Cache does not contain NLog, so I do not expect the GAC to be related to the problem.
Has anyone gone through a similar situation or has any clue?