在VS2010中的.Net 2.0项目中使用托管C++(.Net 2.0)时出现问题
本文关键字:Net C++ 问题 中的 VS2010 项目 | 更新日期: 2023-09-27 18:00:17
我有两个项目:
1) 一个用Visual C++2005编写的项目,目标是.net Framework 2.0。
2) Visual C#2010中的一个项目,该项目以.net framework 2.0为目标,并包含C++DLL。
当我构建引用C++程序集的C#项目时,我会遇到以下错误:
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,它就不会出现这些错误。显然,我不应该为了使用2.0程序集而将其定为4.0目标。
你知道我该怎么解决这个问题吗?
C++项目使用的是v100平台工具集。这使得它依赖于某些库的4.0.NET版本。将工具集更改为v90解决了这个问题。如果您没有v90工具集,您可能需要安装它们。。。