在 Visual Studio 2012 C# 控制台应用程序中,我将“.NET Framework Target”从 4.5 降级到 4.0。安装了两个框架的 Win 7 Pro。
然后我引用一个程序集,该程序集通过警告抱怨以下内容:
The primary reference "System.Threading.Tasks.Dataflow, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the framework assembly "System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0". To resolve this problem, either remove the reference "System.Threading.Tasks.Dataflow, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" or retarget your application to a framework version which contains "System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
如果我尝试在此时进行编译,则会出错,因为引用的程序集的类型和命名空间不可用,就好像该程序集根本没有被引用一样。
“添加引用”对话框没有anySystem.Runtime 选择,但如果我手动浏览到
C:\Windows\Microsoft.NET\Framework\v4.0.30319\
并引用在那里找到的 System.Runtime 程序集,警告消失并且我能够编译。
问题:
这种强制使用 System.Runtime 版本是否会成为未来(部署)的潜在问题?
如果 VS 项目属性设置为目标 Framework 4.0(这与目标 4.0 SystemRuntime/CLR 无关),为什么引用的 DLL 没有选择它,以及为什么手动添加对我的项目的引用可以修复该问题?