I am developing against target framework .NET Framework 3.5
. A project Logger
uses the following library
Newtonsoft.Json.dll
Version = 4.5.0.0
AssemblyFileVersion = 5.0.8.16617
PublicKeyToken = 30ad4fe6b2a6aeed
TargetFramework = v3.5
which is a referenced assembly in the project.
An application MyApp
has a project reference to the Logger
project and so an indirect reference to Newtonsoft.Json.dll
.
Setting the Copy Local
property to true
will enforce Newtonsoft.Json.dll
to be copied to the output directory. Compiling the MyApp
will also copy the Newtonsoft.Json.dll
into the corresponding output directory. Note that there is no Newtonsoft.Json.dll
in the GAC
Fine so far.
Now I installed the following library to the .NET Framework 4.0
GAC (%windir%\Microsoft.NET\assembly
):
Newtonsoft.Json.dll
Version = 4.5.0.0
AssemblyFileVersion = 4.5.8.15203
PublicKeyToken = 30ad4fe6b2a6aeed
TargetFramework = v4.0
Having this library installed in the GAC for .NET Framework 4.0
will cause the project referenced Newtonsoft.Json.dll
is no longer copied to the output directory of MyApp
. But it is still copied to the output directory of Logger
.
I tried to explain this behavior to myself: The project referenced Newtonsoft.Json.dll
is copied to the output directory of Logger
because it's Copy Local
property is set to true
.
But I do not get why the Newtonsoft.Json.dll
is no more copied to the output directory of MyApp
. The library I installed to the GAC of .NET Framework 4.0
should (in my opinion) not be 'visible' to the build system, since my project is built against .NET Framework 3.5
.
At runtime there will be a System.IO.FileNotFoundException
because the Newtonsoft.Json.dll
library is not found (this is clear to me, because the library is located in the 4.0 GAC which is not the GAC 3.5 used by MyApp
).
- Why does the build system of a target framework 3.5 project knows about assemblies in the GAC of
.NET Framework 4.0
? - How do I get the local referenced
Newtonsoft.Json.dll
with target framework 3.5 be copied to the output directory ofMyApp
when there is aNewtonsoft.Json.dll
in the GAC 4.0?