简体   繁体   English

空白 Xamarin.Forms 项目上缺少 netstandard 2.0 程序集错误

[英]Missing netstandard 2.0 assembly error on blank Xamarin.Forms project

I'm getting an error when creating a blank Xamarin.Forms project in VS where the netstandard assembly isn't being referenced, and cannot for the life of me figure out how to fix it.在 VS 中创建一个空白的 Xamarin.Forms 项目时出现错误,其中没有引用 netstandard 程序集,并且我一生都无法弄清楚如何修复它。

The errors I'm getting in the app are:我在应用程序中遇到的错误是:

  • CS0012 C# The type is defined in an assembly that is not referenced. CS0012 C# 类型在未引用的程序集中定义。 You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral,PublicKeyToken=cc7b13ffcd2ddd51'您必须添加对程序集“netstandard, Version=2.0.0.0, Culture=neutral,PublicKeyToken=cc7b13ffcd2ddd51”的引用
  • CS0006 C# Metadata file '..\\bin\\Debug\\netstandard2.0\\ref\\App.dll' could not be found) CS0006 C# 元数据文件 '..\\bin\\Debug\\netstandard2.0\\ref\\App.dll' 找不到)

I have tried, to no avail:我试过了,无济于事:

  • Updating the NETStandard.Library package to 2.0 or higher through NuGet (works for the App.iOS and App.Android projects but not the main App - it says "Blocked by project" for anything above v1.6.1)通过 NuGet 将 NETStandard.Library 包更新到 2.0 或更高版本(适用于 App.iOS 和 App.Android 项目,但不适用于主应用程序 - 对于 v1.6.1 以上的任何内容,它表示“被项目阻止”)
  • Adding a reference to the requested netstandard version in the csproj <Reference Include="netstandard"/> as suggested here: https://github.com/dotnet/standard/issues/542#issuecomment-344591026按照此处的建议在 csproj <Reference Include="netstandard"/>添加对请求的 netstandard 版本的<Reference Include="netstandard"/>https : //github.com/dotnet/standard/issues/542#issuecomment-344591026
  • Adding <Reference Include="System.IdentityModel"/> to the csproj as suggested here: https://github.com/dotnet/standard/issues/542#issuecomment-501309019按照此处的建议将<Reference Include="System.IdentityModel"/>到 csproj: https : //github.com/dotnet/standard/issues/542#issuecomment-501309019
  • Changing <TargetFramework>netstandard2.0</TargetFramework> to<TargetFramework>netstandard2.0</TargetFramework>更改为
    <TargetFrameworks>netstandard2.0</TargetFrameworks> as suggested here: https://github.com/dotnet/standard/issues/542#issuecomment-465375220 <TargetFrameworks>netstandard2.0</TargetFrameworks>如此<TargetFrameworks>netstandard2.0</TargetFrameworks>建议: https : //github.com/dotnet/standard/issues/542#issuecomment-465375220
  • Deleting the bin, obj, .suo, and .vs folders and restarting VS, as well as creating an entirely new Xamarin.Forms blank project删除 bin、obj、.suo 和 .vs 文件夹并重新启动 VS,以及创建一个全新的 Xamarin.Forms 空白项目
  • Updating Xamarin.Essentials and Xamarin.Forms in NuGet在 NuGet 中更新 Xamarin.Essentials 和 Xamarin.Forms
  • Updating to VS Community 2019 16.5.0 Preview 2.0 (where I'd read this issue had been fixed; I've unfortunately misplaced the thread this was in)更新到 VS Community 2019 16.5.0 Preview 2.0(我在那里读到了这个问题已得到修复;不幸的是,我放错了它所在的线程)

This is my csproj (default with the exception of the AutoGenerateBindingRedirects, which was suggested in the comments):这是我的 csproj(默认设置,注释中建议的 AutoGenerateBindingRedirects 除外):

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <ProduceReferenceAssembly>true</ProduceReferenceAssembly>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <DebugType>portable</DebugType>
    <DebugSymbols>true</DebugSymbols>
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Xamarin.Forms" Version="4.3.0.908675" />
    <PackageReference Include="Xamarin.Essentials" Version="1.3.1" />
  </ItemGroup>
  <ItemGroup>
    <Folder Include="ViewModels\" />
  </ItemGroup>
</Project>

Anyone have any idea what to do about this?任何人都知道该怎么做? Most of the answers I've found either don't work or are several years old and are alleged to have been fixed with newer VS versions.我发现的大多数答案要么不起作用,要么已经有好几年了,并且据称已使用较新的 VS 版本进行了修复。

Here's a link to my detailed output logs:这是我的详细输出日志的链接:

VS Community 19 Preview: https://privatebin.net/?c7c4cd6123e0edd7#5qYTwaKSyGKBMgU3beshk3Xgx52nyCyAYcsq63uRfWWT VS 社区 19 预览: https : //privatebin.net/?c7c4cd6123e0edd7#5qYTwaKSyGKBMgU3beshk3Xgx52nyCyAYcsq63uRfWWT

VS Community 19: https://privatebin.net/?2cf9d7ab07e8a4fb#5UkwWhxKFPDGnTtVdZuawkQLMRNe4qvJLeuaBrFrPoJf VS 社区 19: https : //privatebin.net/?2cf9d7ab07e8a4fb#5UkwWhxKFPDGnTtVdZuawkQLMRNe4qvJLeuaBrFrPoJf

Found the problem after two weeks of personal suffering and 2 hours spent with someone experienced with Xamarin!经过两周的个人痛苦和与 Xamarin 经验丰富的人共度 2 小时后发现了问题! The issue was that I had two different versions of dotnet installed (one in the C: drive and one in my E: drive where I also keep program files).问题是我安装了两个不同版本的 dotnet(一个在 C: 驱动器中,另一个在我的 E: 驱动器中,我还保存了程序文件)。 Entered dotnet --version in cmd only to see that the version it found was Ancient (1.x), and then dotnet --list-sdks to find the duplicate one.在cmd中输入dotnet --version只看到它找到的版本是Ancient (1.x),然后dotnet --list-sdks找到重复的版本。 After deleting the old SDK in the E: drive and rechecking my dotnet version the error vanished!删除 E: 驱动器中的旧 SDK 并重新检查我的 dotnet 版本后,错误消失了!

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

相关问题 系统引用缺少Xamarin.Forms .NetStandard - System references missing Xamarin.Forms .NetStandard Xamarin.forms .NetStandard如何播放视频? - Xamarin.forms .NetStandard How to play a video? Xamarin.Forms:Android项目生成错误-AppData \\ Local \\ Xamarin文件夹内缺少文件 - Xamarin.Forms: Android project Build Error - Missing Files inside AppData\Local\Xamarin Folders AppCenter构建因Xamarin.Forms android项目错误而失败:无法找到程序集“ Mono.Android” - AppCenter build failing for Xamarin.Forms android project error: Could not locate the assembly “Mono.Android” Xamarin.Forms 程序集引用 - Xamarin.Forms assembly references Jenkins无法通过缺少对程序集Netstandard的引用来构建Xamarin iOS项目 - Jenkins cannot build Xamarin iOS project over a missing reference to assembly netstandard 在Android上关闭应用程序后,Prism + Xamarin.Forms Project错误? - Prism + Xamarin.Forms Project error after closing app on Android? 错误“框架不在模块中”。 在 Xamarin.Forms - Android 项目中 - Error "Frame not in module." in Xamarin.Forms - Android project 在Xamarin.Forms中创建新项目时出现错误 - Getting Error while creating new project in Xamarin.Forms 使用Prism为Xamarin.Forms创建新项目时出错 - Error on creating new project with Prism for Xamarin.Forms
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM