2011-06-23 53 views
2

NET 2.0的項目中使用託管C++(.NET 2.0)我有兩個項目:問題在VS2010

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。

有關如何解決這個問題的任何想法?

+0

您是否轉換了C++/CLI項目?不要,只添加參考。 –

+0

不,ScanWizard DLL最近一次編譯是在4年前的Visual C++ 2005.它沒有被重新編譯或者任何東西。它不應該也不需要,但是如果在我編譯時我可以做不同的事情,那我很樂意。 –

+0

通過使用ILSpy,我能夠發現VC++ DLL具有對MFCMIFC80的引用,這取決於mscorlib和System。它不是使用2.0版本,而是使用系統上的最新版本,即4.0。必須有辦法阻止它這樣做? –

回答

1

C++項目正在使用v100平臺工具集。這使得它依賴於某些庫的4.0 .NET版本。將工具集更改爲v90可解決問題。如果您沒有它們,您可能需要安裝v90工具集...