I'm using VS2015 and working in a solution with numerous projects.
One project in my solution (call it "MyDllProject") is a class library targeted for .NET version 4.0. It does itself reference numerous dlls, including (in this case) System.Windows.Forms. The reference in the project file is as follows:
<Reference Include="System.Windows.Forms" />
So it is not referencing a specific version. From the properties tab, it seems it is picking up that file from the following location:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\System.Windows.Forms.dll
On my system, I have numerous other versions of System.Windows.Forms in various other subdirectories (v3.5, v4.5, v4.5.1, v4.6, v4.6.1) under the C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\ root. But it seems to me my system is getting the right one.
MyDllProject builds just fine, cleans fine, rebuilds fine and seems happy as a clam.
Numerous other projects in my solution also refer to MyDllProject and they themselves also build, clean, and rebuild just fine.
HOWEVER.... there is an old ASMX web site "project" in this solution. ASMX websites don't have project files per se.... all their project information is in the solution file. Not sure if that is relevant. Like everything else in the solution, this ASMX web site is targetted for .net version 4.0. And when I build that web site, either by building the entire solution or by just building the web site project, I get the following warning:
(0,0): warning : The following assembly has dependencies on a version of the .NET Framework that is higher than the target and might not load correctly during runtime causing a failure: MyDllProject, Version=14.0.0.0, Culture=neutral, PublicKeyToken=null. The dependencies are: System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089. You should either ensure that the dependent assembly is correct for the target framework, or ensure that the target framework you are addressing is that of the dependent assembly.
Now everything seems to work generally in my MyDllProject, and in the ASMX web site, but I like to follow the best practices and get warnings out of my build, or at least understand them. And I don't fully understand how this warning comes about, how it comes ONLY from building this one ASMX web site, and how to get rid of it.
Thanks in advance for any insights or suggestions.