便携式类库 - 你必须添加一个引用程序集“System.Net,版本= 2.0.5.0 [英] Portable Class Library - you must add a reference to assembly 'System.Net, Version=2.0.5.0

查看:350
本文介绍了便携式类库 - 你必须添加一个引用程序集“System.Net,版本= 2.0.5.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个可移植类库目标4.0。一个WPF应用程序引用这是一个标准的.NET 4.0应用程序。

We have a Portable Class Library targeting 4.0. A WPF application references this which is a standard .NET 4.0 app.

的PCL引用System.Net.NetworkCredential类。

The PCL references the System.Net.NetworkCredential class.

当我们构建在.NET 4.0的应用程序,我们得到一个错误:

When we build the .NET 4.0 app we get an error:

The type 'System.Net.NetworkCredential' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Net, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'.

几个帖子说安装KB2468871。这并不适用/改变的事情。

Several posts say to install KB2468871. That doesn't apply/change things.

如果我们在应用程序中添加程序集引用System.Net 4.0.0.0,那么误差变化:

If we add an assembly reference to "System.Net 4.0.0.0" in the app then the error changes:

Reference to type 'System.Net.NetworkCredential' claims it is defined in 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Net.dll', but it could not be found...

当然的NetworkCredential不在System.Net,它是在系统组装

Of course NetworkCredential is not in System.Net, it is in the System assembly.

如果我重新定位到4.5一切正常,但我们需要使用4.0。

If I retarget to 4.5 everything works, but we need to use 4.0.

任何想法?谢谢你。

推荐答案

KB2468871使便携式库在4.0上运行,它不会让他们建在Visual Studio中。

KB2468871 enables portable libraries to run on 4.0, it does not enable them to build in Visual Studio.

第一个错误应该消失,如果你添加一个引用System.Net,4.0.0.0。如果没有,那么你的机器缺少必需的补丁。

The first error should go away if you add a reference to System.Net, 4.0.0.0. If it does not, then you're machine is missing a required patch.

如果使用的是:

的Visual Studio 2010

您需要安装可移植库工具:的http://visualstudiogallery.msdn.microsoft.com/b0e0b5e9-e138-410b-ad10-00cb3caf4981/.这将安装一个补丁,这将使这项工作。

You need to install Portable Library Tools: http://visualstudiogallery.msdn.microsoft.com/b0e0b5e9-e138-410b-ad10-00cb3caf4981/. This will install a patch that will make this work.

的Visual Studio 2012或Visual Studio 2013

这应该工作的开箱即用,如果没有,那么你安装很可能会在一个不完整的状态。尝试修复安装。

This should work out of the box, if not, then you install is likely in an incomplete state. Try repairing your installation.

这篇关于便携式类库 - 你必须添加一个引用程序集“System.Net,版本= 2.0.5.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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