Вопрос

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?

Это было полезно?

Решение

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top