简体   繁体   English

间接依赖 - .NET2.0 - WMP.dll

[英]Indirect dependency - .NET2.0 - WMP.dll

After installing Visual Studio 2017 RC, I have some code that cannot build. 安装Visual Studio 2017 RC后,我有一些无法构建的代码。 I have narrowed it down to WMP and .NET Framework 2 (it works under Framework 4) 我已将其缩小到WMP和.NET Framework 2(它在框架4下工作)

The most basic test setup is 2 projects: 最基本的测试设置是2个项目:

Project 1: 项目1:

  • Windows Forms App Windows窗体应用程序
  • .NET Framework 2.0 .NET Framework 2.0
  • Namespace WMPClient 命名空间WMPClient
  • Reference added to wmp.dll (have tried both system32 and syswow64) 引用添加到wmp.dll(已尝试过system32和syswow64)
  • Added Windows Media Player to Form1.cs 将Windows Media Player添加到Form1.cs

Project 2: 项目2:

  • Class Library (.NET Framework) 类库(.NET Framework)
  • .NET Framework 2.0 .NET Framework 2.0
  • Namespace WMPLib 命名空间WMPLib
  • Reference added to WMPClient 参考添加到WMPClient

Both projects build. 这两个项目都在建

When adding using WMPClient; using WMPClient;添加using WMPClient; to Class1.cs (project 2) the build fails: Class1.cs (项目2),构建失败:

13 error lines like System.Windows.Forms, mscorlib, System 13个错误行,如System.Windows.Forms, mscorlib, System

warning MSB3258: The primary reference "C:\\WMPClient\\bin\\Debug\\WMPClient.exe" could not be resolved because it has an indirect dependency on the .NET Framework assembly "System.Windows.Forms, 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.

1 error line like this: 像这样的1个错误行:

error CS0246: The type or namespace name 'WMPClient' could not be found (are you missing a using directive or an assembly reference?)

The same code does not work under VS2013 anymore either, but did before installing VS2017 相同的代码在VS2013下也不起作用,但在安装VS2017之前做了

it says your "WMPClient.exe" has a higher version 4.0 of .net framework. 它说你的“WMPClient.exe”有更高版本的4.0 .net框架。 And by principle one cannot add higher version libraries or namespaces in a lower .NET version project. 原则上,不能在较低的.NET版本项目中添加更高版本的库或命名空间。 So, Either build "WMPClient.exe" with 2.0, or upgrade your Forms Project to 4.0 因此,使用2.0构建“WMPClient.exe”,或将Forms Project升级到4.0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM