使用托管C ++(.NET 2.0)在NET 2.0的项目在VS2010问题项目、问题、NET

2023-09-03 15:09:43 作者:つ低吟未央的流年。

我有两个项目:

1)用Visual C ++ 2005中的一个项目,该项目面向.NET Framework 2.0。

1) a project written in Visual C++ 2005 which targets the .net Framework 2.0.

2)在Visual C#2010一个项目,针对.NET Framework 2.0和包括C ++的DLL。

2) a project in Visual C# 2010 that targets .net framework 2.0 and includes the C++ DLL.

当我生成C#项目引用的C ++组件,我得到这样的错误:

When I build the C# project referencing the C++ assembly, I get errors like:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3258: The primary reference "ScannerWizard" 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(1360,9): warning MSB3258: The primary reference "ScannerWizard" could not be resolved because it has an indirect dependency on the .NET Framework assembly "System, 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(1360,9): warning MSB3258: The primary reference "ScannerWizard" could not be resolved because it has an indirect dependency on the .NET Framework assembly "System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 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(1360,9): warning MSB3258: The primary reference "ScannerWizard" could not be resolved because it has an indirect dependency on the .NET Framework assembly "System.Xml, 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(1360,9): warning MSB3258: The primary reference "ScannerWizard" could not be resolved because it has an indirect dependency on the .NET Framework assembly "System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 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(1360,9): warning MSB3258: The primary reference "ScannerWizard" could not be resolved because it has an indirect dependency on the .NET Framework assembly "System.Data.SqlXml, 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.

如果我做的项目4.0,它不给这些错误。很显然,我不应该让目标4.0使用2.0组件。

If I make the project 4.0, it doesn't give those errors. Obviously, I shouldn't have to make it target 4.0 to use a 2.0 assembly.

我如何才能解决这个问题的任何想法?

Any idea on how I can fix this?

推荐答案

C ++的项目使用V100的平台工具。这使得它依赖于.NET 4.0版本的一些库。更改工具集V90解决了这个问题。您可能需要安装V90工具,如果你没有他们...

The C++ project was using the v100 Platform toolset. This makes it depend on 4.0 .NET versions of some libraries. Changing the toolset to v90 solves the problem. You may need to install the v90 toolset if you don't have them...