I created a new C++/CLI project in Visual Studio 2012, with .NET 2.0 selected as the framework on the project creation page. I have verified the "External Dependencies" (mscorlib.dll, System.Data.dll, System.dll, and System.XML.dll) show "Path" as being c:\Windows\Microsoft.NET\Framework\v2.0.50727\*
.
When adding a reference to this project from a C# .NET 2.0 project in the same solution, at build time the compiler cannot link against my C++ library with the following error:
Warning 2 The primary reference "D:\GIT\EasyBCD\Release\Win32Interop.dll" could not be resolved because it has an indirect dependency on the .NET Framework assembly "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which has a higher version "4.0.0.0" than the version "2.0.0.0" in the current target framework. C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.Targets 1578
However, like I said, the references in the 'Win32Interop' project clearly indicate v2.0 was used, and the project file itself contains <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
as it should.
Why is Visual Studio 2012 giving me such a hard time?
EDIT
The mystery deepens. When attempting to remove all and then re-add .NET references in the C++/CLI project, this is what shows:
As you can see, at the top it says "Targeting: .NET Framework 2.0" and the "Version" column indicates that I am selecting version "2.0.0.0".
However, upon clicking OK, this is what the references list looks like:
The Targeted framework remains ".NETFramework,Version=v2.0" but the individual references each indicate that version "4.0.0.0" is being used (along with the public key tokens for that version of the file).
Yet the properties dialog when selecting each reference absolutely maintains that the v2.0 file is being used. Whom to believe? What to do?
It appears that creating a .NET 2.0 CLR project is not supported. Here's the link on Microsoft Connect:
https://connect.microsoft.com/VisualStudio/feedback/details/780602/compiling-c-clr-dll-in-vs-2012-targeting-net-2-0-introduces-indirect-dependency-on-net-4-0#tabs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With