繁体   English   中英

添加了在visual studio中未检测到的引用

[英]Added reference not detected in visual studio

在尝试安装netmq vis nuget时,出现以下错误:

Could not install package 'AsyncIO 0.1.18'. You are trying to install this package
 into a project that targets '.NETPortable,Version=v4.5,Profile=Profile111',
 but the package does not contain any assembly references or content files that
 are compatible with that framework. For more information, contact the package author.

问题是netmq依赖于AsyncIO。 安装时,nuget发现程序集与.Net 4.5不兼容。

所以nuget在安装AsyncIO时失败,然后安装netmq失败了。

所以我从Github下载了AsyncIO Source,并使用.Net 4.5在本地构建它。

之后,添加了本地构建的AsyncIO dll作为我项目的参考。

从理论上讲,NetMQ应该与nuget一起成功安装。 因为我添加了AsyncIO所需的引用。

但是当我尝试重新安装NetMQ时,我得到了同样的错误:

Could not install package 'AsyncIO 0.1.18'. You are trying to install this package
 into a project that targets '.NETPortable,Version=v4.5,Profile=Profile111',
 but the package does not contain any assembly references or content files that
 are compatible with that framework. For more information, contact the package author.

并且nuget没有检测到我在我的项目中添加了“AsyncIO 0.1.18”。

如何让nuget检测到我在项目中添加了这个引用?

看看这里:

.NET Portable配置文件

Profile111是以下组合:

  • .NET Framework 4.5
  • Windows 8.0
  • Windows Phone 8.1

换句话说:portable-net45 + netcore45 + wpa81

因此,您尝试将NuGet附加到Windows Phone 8.1和其他2个平台的项目,我提到这个是最严格的。

现在让我们来看看命名的NuGet包的来源

 <ProjectGuid>{3830B7A3-0225-4FDA-B155-E085E183650C}</ProjectGuid> 
 <OutputType>Library</OutputType> 
 <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> 
 <TargetFrameworkProfile> 
 </TargetFrameworkProfile> 

我们有什么在这里? 我们可以看到该项目不是PCL。 它的目标是完整的.NET 4.0框架,这在Windows Phone 8.1上是不可用的。 您的图书馆确实以Windows Phone 8.1为目标。 看到问题?

你说如果编译AsyncIO定位.NET 4.5,你可以成功地将它作为参考附加到你的项目中吗? 这并非完全正确。 我的意思是你可以附加一个引用,但你不能使用它。 当您尝试从该引用中调用某些内容时,您将看到该内容。

为了使用您的AsyncIO,PCL必须将AsyncIO构建为针对相同或更严格的平台集的PCL。 尝试创建一个针对Profile111的PCL项目,并尝试使用它编译AsyncIO代码(只需将原始AsyncIO源文件(* .cs)链接到这个新的AsyncIO_PCL项目中)。 如果你足够幸运并且AsyncIO的代码真的兼容,你将能够使用该库。

这是你的步骤:

  1. 创建一个类型为PCL类库的新项目(名为AsyncIO_PCL)。
  2. 选择Profile111平台集ie
    • .NET Framework 4.5
    • Windows 8.0
    • Windows Phone 8.1
  3. 链接原始AsyncIO项目中的所有.cs文件,将一个(AssemblyInfo.cs)保存到新的AsyncIO_PCL项目中。
  4. 将输出程序集名称设置为与原始AsyncIO项目中的名称相同。
  5. 尝试构建项目。

您将AsyncIO构建为具有所需支持平台的PCL的能力取决于AsyncIO代码,即内部使用的API以及您所针对的所有三个平台是否支持该API。

尝试单击项目上的右键 - >属性。 在“应用程序”菜单中,选中“目标框架”。 它应该设置为.NET Framework 4.5

暂无
暂无

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

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