【问题标题】:Ho to reference .NETPortable,Version=v4.6,Profile=Profile44如何引用.NET Portable,Version=v4.6,Profile=Profile 44
【发布时间】:2019-04-23 21:01:31
【问题描述】:

编辑:由于无法通过使用提供的答案解决问题。我接受了切换到 .NetStandard 的建议,这就是答案被接受的原因。

我收到此错误,但无法解决:

您的项目未引用“.NETPortable,Version=v4.6,Profile=Profile44”框架。在项目文件的“TargetFrameworks”属性中添加对“.NETPortable,Version=v4.6,Profile=Profile44”的引用,然后重新运行 NuGet 恢复。

我的 .csproj 看起来像这样:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <MinimumVisualStudioVersion>10.0</MinimumVisualStudioVersion>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{1D5637E9-E724-4943-A535-5B61D0C1C4BC}</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>xxx.xxx.xxx/RootNamespace>
    <AssemblyName>xxx.xxx.xxx</AssemblyName>
    <DefaultLanguage>en-US</DefaultLanguage>
    <FileAlignment>512</FileAlignment>
    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
    <TargetFrameworkProfile>Profile44</TargetFrameworkProfile>
    <TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
    <SccProjectName>SAK</SccProjectName>
    <SccLocalPath>SAK</SccLocalPath>
    <SccAuxPath>SAK</SccAuxPath>
    <SccProvider>SAK</SccProvider>
  </PropertyGroup>

既然已经有了

    <TargetFrameworkProfile>Profile44</TargetFrameworkProfile>
    <TargetFrameworkVersion>v4.6</TargetFrameworkVersion>

在里面我不知道该怎么办。

我恢复了 NuGet,但没有要恢复的内容。

我的项目属性如下所示:

我不知道我可以改变什么来解决这个问题。

提前致谢。

【问题讨论】:

  • 您是否尝试通过右键单击项目下的引用然后Add Reference...来添加引用?
  • 我不知道该添加哪一个即使在我下载的程序集中也没有这个名称的dll

标签: c# visual-studio build portable-class-library


【解决方案1】:

你收到this pack of assemblies 了吗? 如果没有,请安装它并确保将内容放在正确的文件夹中,例如C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework

但是,由于已弃用,建议改用 .NETStandard,有关介绍,请参阅 this article on MSDN

【讨论】:

  • 好的,我下载了,现在?我恢复了,但什么也没发生,所以我要卸载它们还是什么? ^^ 我考虑更改类型,但首先我需要让我的项目运行,因为库已经实现
  • 您可以先尝试添加一个新的 Portable-Class-Library 吗?通常,您的 csproj 底部会有一个导入标签,例如:
  • 标签存在于新旧项目中
  • 我使用 VS 对它们进行了比较,没有任何区别可能是问题所在。由于公司的安全准则,我无法提供项目。我的同事已经将类库实现为 .NetStandard
  • 非常抱歉,我无法提供所需的信息,因此问题将一直无人回答,但我非常感谢您的努力。谢谢!
【解决方案2】:

我也遇到了这个问题,上面的任何解决方案都不起作用, 但是问题是 Obj 文件夹中有一个额外的 project.assets.json 和 project.nuget.cache 文件。

这很可能是分支交换机的遗留问题。 删除此文件夹/文件后。问题已解决。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-23
    • 1970-01-01
    • 1970-01-01
    • 2011-04-02
    • 1970-01-01
    • 2021-01-10
    相关资源
    最近更新 更多