在VS 2012 RC参考TPL数据流和第三方物流存在的问题 [英] Problems with references to TPL Dataflow and TPL in VS 2012 RC

查看:356
本文介绍了在VS 2012 RC参考TPL数据流和第三方物流存在的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚升级的Visual Studio 11 Beta版到新的Visual Studio 2012 RC和有参考TPL数据流的问题。

I just upgraded Visual Studio 11 Beta to the new Visual Studio 2012 RC and have problems referencing TPL Dataflow.

首先,我想引用的数据流和我一样previously,加入从框架的参考。但是,当我尝试这样做,我得到一个错误对话框:

First, I tried to reference Dataflow as I did previously, by adding a reference from the framework. But when I try to do that, I get an error box:

一提到'System.Threading.Tasks.Dataflow不能添加。

A reference to 'System.Threading.Tasks.Dataflow' could not be added.

然后整个Visual Studio的冻结。

and then the whole Visual Studio freezes.

看完<一href="http://blogs.msdn.com/b/bclteam/archive/2012/05/30/mef-and-tpl-dataflow-nuget-packages-for-net-framework-4-5-rc.aspx">MEF和TPL数据流的NuGet软件包用于.NET Framework 4.5 RC ,我以为数据流的,在参考文献列表中显示,是某种的previous安装工件的版本。所以,我尝试使用数据流从的NuGet,这似乎工作,直到我真正试图编译我的code,因为我得到了一个错误:

After reading MEF and TPL Dataflow NuGet Packages for .NET Framework 4.5 RC, I assumed the version of Dataflow that showed in the references list was some kind of artifact of the previous installation. So, I tried using Dataflow from NuGet, which seemed to work, until I actually tried to compile my code, because I got an error:

类型System.Threading.Tasks.Task'中未被引用的组件被定义。您必须添加一个引用程序集System.Threading.Tasks,版本= 4.0.0.0,文化=中性公钥= b03f5f7f11d50a3a'。

The type 'System.Threading.Tasks.Task' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Threading.Tasks, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

这是令人困惑,因为工作在mscorlib中,没有其他的参考应该是必要的。但是,有一个名为 System.Threading.Tasks 在引用列表中的引用程序集,所以我想补充一点。不幸的是,一个熟悉的错误表明:

This is confusing, because Task is in mscorlib, no other references should be necessary. But there is a reference assembly called System.Threading.Tasks in the references list, so I tried to add that. Unfortunately, a familiar error showed:

一提到'System.Threading.Tasks不能添加。

A reference to 'System.Threading.Tasks' could not be added.

然后Visual Studio中再次呆住了。

and then Visual Studio froze again.

我是不是做错了什么?我如何使用TPL数据流与VS 2012 RC?

Am I doing something wrong? How can I use TPL Dataflow with VS 2012 RC?

推荐答案

尝试添加引用的 System.Threading.Tasks.dll 明确地 C:\ Program Files文件(x86)的\参考大会\微软\框架\ .NETCore \ V4.5 。或者您可以使用 C:\ Program Files文件(x86)的\参考大会\微软\框架\ .NETFramework \ V4.5 \外立面目录

Try to "Add Reference" the System.Threading.Tasks.dll explicitly from C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5. Alternatively you can use C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Facades directory.

更新时间::我在研究这个问题更多的阅读的有关删除参考答案以 System.Runtime ,我可以添加以下内容:提及因为错误的 System.Runtime 将增加在的NuGet包的确认当期的版本 Microsoft.Tpl.Dataflow.4.5.1-RC 。如果一个引用添加到同一个 System.Threading.Tasks.Dataflow.dll 直接在Visual Studio中没有 System.Runtime 参考将被添加和没有问题存在。

UPDATED: I examined the problem more after reading of the answer about removing the reference to System.Runtime and I can add the following: The reference to System.Runtime will be added because of the error in the currect version of NuGet package Microsoft.Tpl.Dataflow.4.5.1-rc. If one add the reference to the same System.Threading.Tasks.Dataflow.dll directly in Visual Studio no System.Runtime reference will be added and no problem exist.

使用的NuGet软件包浏览器可以下载原版 Microsoft.Tpl .Dataflow.4.5.1-rc.nupkg 从的NuGet官方包源。在包Matadata之一年底将看到

Using NuGet Package Explorer one can download the original Microsoft.Tpl.Dataflow.4.5.1-rc.nupkg from the "NuGet official package source". At the end of the Package Matadata one will see

我们可以修改元数据(preSS 按Ctrl-K ),并删除引用:

One can modify the metadata (press Ctrl-K) and remove the reference:

在一个可以保存修改后的文件 Microsoft.Tpl.Dataflow.4.5.1-rc.nupkg 在某些目录中。在的NuGet源列表中添加新的位置(本地目录)后(见这里或<一href="http://haacked.com/archive/2010/10/21/hosting-your-own-local-and-remote-nupack-feeds.aspx">here)一会就能从本地源添加新包(别忘了选择显示所有包含pre释放见下图):

After that one can save the modified file Microsoft.Tpl.Dataflow.4.5.1-rc.nupkg in some directory. After adding new location (the local directory) in the list of NuGet sources (see here or here) one will be able to add new package from the local source (don't forget to choose to display all packages inclusive pre-release see the picture below):

修改后的 Microsoft.Tpl.Dataflow.4.5.1-rc.nupkg 将不添加 System.Runtime 该项目将没有错误被编译。

The modified Microsoft.Tpl.Dataflow.4.5.1-rc.nupkg will not add System.Runtime and the project will be compiled without errors.

所以这个bug存在不能在Visual Studio 2012 RC,甚至没有在 Microsoft.Tpl.Dataflow.dll 。该bug只是在 Microsoft.Tpl.Dataflow 的pre-发行版本的NuGet封装,目前的NuGet官方包源的元数据。

So the bug exist not in Visual Studio 2012 RC and even not in Microsoft.Tpl.Dataflow.dll. The bug is just in the metadata of the pre-release version of Microsoft.Tpl.Dataflow NuGet package available currently on "NuGet official package source".

您可以张贴到 autors 这样包将被固定的bug报告。

You can post the bug report to the autors so that the package will be fixed.

更新2 :即使我的答案被标记为已解决,赏金授予问题依然从我的头不走。在现实中,我看到两个打开的问题:

UPDATED 2: Even if my answer are already marked as solved and the bounty awarded the problem still not go from my head. In reality I see two opened problems:

  1. 为什么不使用的组件中存在 System.Runtime 可以在项目的builging过程中产生错误。
  2. 我看到这样一些一般性的问题,卸载或的NuGet包更新是如何工作的(见后面详细说明)。
  1. Why the existence of unused assembly System.Runtime can produce the error during the builging of the project.
  2. I see some general problems in the way how Uninstall or Update of NuGet packages works (see details later).

让我们我们接受只是一个事实,即第一个问题从原因存在独立的。第二个问题让我坐立不安。我看到了真正的问题在这里。每个人都可以做以下实验清楚地明白我:

Let us we accept just the fact that the first problem exist independent from the reason. The second problem make me restlessness. I see the real problem here. Everybody can make the following experiment to understand me better:

  1. 创建在Visual Studio 2012 RC一个新的空的控制台应用程序。
  2. 验证项目没有引用 System.Runtime
  3. 开启软件包管理器控制台,从工具/库程序包管理器。
  4. 执行命令。安装,包装Microsoft.Tpl.Dataflow - pre 的,在包管理器控制台
  5. 验证两个 System.Runtime System.Threading.Tasks.Dataflow 被列入参考名单该项目。
  6. 执行命令的卸载,包Microsoft.Tpl.Dataflow 的,在包管理器控制台。
  7. 验证 System.Threading.Tasks.Dataflow 从项目引用的列表中删除,但是 System.Runtime 仍是引用。
  1. Create a new empty console application in Visual Studio 2012 RC.
  2. Verify that the project has no reference to System.Runtime.
  3. Open "Package Manager Console" from "Tools" / "Library Package Manager".
  4. Execute the command "Install-Package Microsoft.Tpl.Dataflow -Pre" in the "Package Manager Console".
  5. Verify that both System.Runtime and System.Threading.Tasks.Dataflow are included in the list of References of the project.
  6. Execute the command "Uninstall-Package Microsoft.Tpl.Dataflow" in the "Package Manager Console".
  7. Verify that System.Threading.Tasks.Dataflow are removed from the list of References of the project, but System.Runtime is still in the list of references.

我做了一个更多的实验,我改变的版本修改 Microsoft.Tpl.Dataflow.4.5.1-rc.nupkg ,在这里我删除了引用 System.Runtime ,从 4.5.1-RC 4.5.1-RC1 ,并将其保存在本地(它会在 Microsoft.Tpl.Dataflow.4.5.1-rc1.nupkg保存)。从那以后,我可以看到新版本的更新列表,以我的项目:

I made one more experiment and I changed the version of modified Microsoft.Tpl.Dataflow.4.5.1-rc.nupkg, where I removed the reference to System.Runtime, from 4.5.1-rc to 4.5.1-rc1 and saved it locally (it will be saved under Microsoft.Tpl.Dataflow.4.5.1-rc1.nupkg). After that I could see "new" version in the list of Updates to my project:

如果我安装更新的参考 System.Runtime 也将不会被删除。

If I install the Update the reference to System.Runtime will be also not removed.

所以,更新和卸载的NuGet的目前执行有错误或一般的设计问题。如果我们增加了一个包,我们的项目,使该项目的一些更新,我们会得到所有旧版本的所有相关组件的参考。 旧的参考文献,通过的NuGet从旧版本的软件包增加,将不卸载或更新中删除。首先,这不是很好本身具有垃圾项目中的引用,但(如果 System.Runtime 存在编译时错误引用未引用的),因为存在的第一个问题问题将更加严重。

So the current implementation of "Update" and "Uninstall" of NuGet has the bug or general design problem. If we added a package to our project and make some updates of the project we will get references of all dependent assemblies of all old versions. The old references, added by NuGet from old versions of the package, will be not removed during Uninstall or Update. First of all it's not good itself to have garbage in the project references, but because of existence the first problem (error during compilation if the reference to unreferenced System.Runtime exist) the problem will be even more serious.

因此​​,如果没有将的NuGet更新更改为下一版本的 Microsoft.Tpl.Dataflow 解决不了的谁安装的用户的问题 Microsoft.Tpl.Dataflow 在4.5.1版本(或者可能是早期的版本)。所有的用户将必须手动删除提及 System.Runtime。我认为这是真正的NuGet问题,这必须由开发商的NuGet来解决。我会后问题的描述 http://nuget.org/ 后。

So if nothing will be changed in NuGet the update to the next version of Microsoft.Tpl.Dataflow will not solve the problem for the users who installed Microsoft.Tpl.Dataflow in version 4.5.1 (or probably early version). All users will have to remove the reference to System.Runtime manually. I think that it's real NuGet problem which have to be solved by NuGet developers. I will post the description of the problem to http://nuget.org/ later.

我要发布的NuGet的bug报告可以发现这里 (抱歉的不健全格式文本)。

The bug report which I posted to NuGet can be found here (sorry for not perfect formatting of the text).

这篇关于在VS 2012 RC参考TPL数据流和第三方物流存在的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆