使用PCL“TPL Dataflow”的项目在编写.NET 4.5.2时无法编译(Project using PCL 'TPL Dataflow' won't compi

编程入门 行业动态 更新时间:2024-10-27 22:34:49
使用PCL“TPL Dataflow”的项目在编写.NET 4.5.2时无法编译(Project using PCL 'TPL Dataflow' won't compile when targetting .NET 4.5.2)

我正在使用Windows 7 Pro x64 SP1和Visual Studio 2012 Update 4.在使用TPL Dataflow包和.NET 4.5.2时,我无法编译我的VB.NET WPF项目。 我创建了一个除了这段代码之外什么都没有的基础项目,只为x64编译:

Imports System.Threading.Tasks.Dataflow Class MainWindow Dim test As New System.Threading.Tasks.Dataflow.BufferBlock(Of String) End Class

我已经尝试添加Facical引用到System.Runtime.dll和System.Diagnostics.Tracing.dll没有任何效果。 如果我改为.NET 4.5,它编译得很好。 我必须引用4.5.2,因为项目中需要它的其他功能。

具体错误:

警告1无法解析主要参考“System.Threading.Tasks.Dataflow,Version = 4.5.23.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a,processorArchitecture = MSIL”,因为它对框架程序集“System.Runtime”具有间接依赖性,Version = 4.0.10.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a“无法在当前目标框架中解析。 ” .NETFramework,版本= v4.5.2" 。 要解决此问题,请删除引用“System.Threading.Tasks.Dataflow,Version = 4.5.23.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a,processorArchitecture = MSIL”或将应用程序重新定位到包含“System.Runtime”的框架版本,Version = 4.0.10.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a“。 TPLDataflow4.5.2Demo

警告2无法解析主要参考“System.Threading.Tasks.Dataflow,Version = 4.5.23.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a,processorArchitecture = MSIL”,因为它对框架程序集“System.Diagnostics”具有间接依赖性.Tracing,Version = 4.0.10.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a“无法在当前目标框架中解析。 ” .NETFramework,版本= v4.5.2" 。 要解决此问题,请删除引用“System.Threading.Tasks.Dataflow,Version = 4.5.23.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a,processorArchitecture = MSIL”或将应用程序重新定位到包含“System.Diagnostics”的框架版本.Tracing,Version = 4.0.10.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a“。 TPLDataflow4.5.2Demo

警告3 Imports的System.Threading.Tasks.Dataflow'中指定的命名空间或类型不包含任何公共成员或无法找到。 确保定义了名称空间或类型,并且至少包含一个公共成员。 确保导入的元素名称不使用任何别名。 F:\ Projects \ TPLDataflow4.5.2Demo \ TPLDataflow4.5.2Demo \ MainWindow.xaml.vb 1 9 TPLDataflow4.5.2Demo

错误4类型'System.Threading.Tasks.Dataflow.BufferBlock'未定义。 F:\ Projects \ TPLDataflow4.5.2Demo \ TPLDataflow4.5.2Demo \ MainWindow.xaml.vb 4 21 TPLDataflow4.5.2Demo

解:

事实证明,我使用的Microsoft .NET Framework 4.5.2开发人员包有一个不允许PCL正确编译的错误。

我从http://support.microsoft.com/kb/2901951下载并安装了Microsoft .NET Framework 4.5.2 Developer Pack的更新版本,我的应用程序能够无错误地编译。

I'm using Windows 7 Pro x64 SP1 and Visual Studio 2012 Update 4. I can't get my VB.NET WPF project to compile when using the TPL Dataflow package and .NET 4.5.2. I've created a base project with nothing except this code and compile only for x64:

Imports System.Threading.Tasks.Dataflow Class MainWindow Dim test As New System.Threading.Tasks.Dataflow.BufferBlock(Of String) End Class

I've tried adding the facade reference to System.Runtime.dll and System.Diagnostics.Tracing.dll with no effect. It compiles fine if I change to .NET 4.5. I must have a reference to 4.5.2 because of other features that will be in the project that require it.

Specific errors:

Warning 1 The primary reference "System.Threading.Tasks.Dataflow, Version=4.5.23.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.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.5.2". To resolve this problem, either remove the reference "System.Threading.Tasks.Dataflow, Version=4.5.23.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" or retarget your application to a framework version which contains "System.Runtime, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". TPLDataflow4.5.2Demo

Warning 2 The primary reference "System.Threading.Tasks.Dataflow, Version=4.5.23.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the framework assembly "System.Diagnostics.Tracing, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.5.2". To resolve this problem, either remove the reference "System.Threading.Tasks.Dataflow, Version=4.5.23.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" or retarget your application to a framework version which contains "System.Diagnostics.Tracing, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". TPLDataflow4.5.2Demo

Warning 3 Namespace or type specified in the Imports 'System.Threading.Tasks.Dataflow' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases. F:\Projects\TPLDataflow4.5.2Demo\TPLDataflow4.5.2Demo\MainWindow.xaml.vb 1 9 TPLDataflow4.5.2Demo

Error 4 Type 'System.Threading.Tasks.Dataflow.BufferBlock' is not defined. F:\Projects\TPLDataflow4.5.2Demo\TPLDataflow4.5.2Demo\MainWindow.xaml.vb 4 21 TPLDataflow4.5.2Demo

Solution:

It turns out the Microsoft .NET Framework 4.5.2 Developer Pack I was using had a bug that wouldn't let PCLs compile correctly.

I downloaded and installed the updated version of the Microsoft .NET Framework 4.5.2 Developer Pack from http://support.microsoft.com/kb/2901951 and my application was able to compile without errors.

最满意答案

在连接上有一个票证,指定使用.NET 4.5.2与PCL库导致构建失败。

这已在Microsoft .NET Framework 4.5.2 Developer Pack中修复

当您重新编译使用.NET可移植库来定位Microsoft .NET Framework 4.5.2的Microsoft .NET Framework 4.5.1应用程序时,您在编译期间收到以下错误消息:

类型“{type}”在未引用的程序集中定义。 您必须添加对程序集“{assembly}”的引用

There is a ticket on connect specifying the use of .NET 4.5.2 with PCL libraries causing builds to fail.

This was fixed in the Microsoft .NET Framework 4.5.2 Developer Pack

When you recompile a Microsoft .NET Framework 4.5.1 application that uses .NET portable libraries to target the Microsoft .NET Framework 4.5.2, you receive the following error message during compilation:

The type '{type}' is defined in an assembly that is not referenced. You must add a reference to assembly '{assembly}'

更多推荐

本文发布于:2023-08-02 00:51:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1368037.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:项目   Dataflow   PCL   TPL   NET

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!