Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

New .NET 2.0 C++/CLI project has implicit dependency on mscorlib v4?

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:

Adding new dependency

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:

.NET dependency list

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?

like image 794
Mahmoud Al-Qudsi Avatar asked Feb 14 '13 23:02

Mahmoud Al-Qudsi


1 Answers

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

like image 106
snowdude Avatar answered Oct 11 '22 18:10

snowdude