简体   繁体   English

缺少编译器所需的成员,但已添加 Microsoft.CSharp package

[英]Missing compiler required member but have already added Microsoft.CSharp package

I am trying to run a Xamarin.Forms application where the .Core project is .NET Standard 2.0 .我正在尝试运行 Xamarin.Forms 应用程序,其中.Core项目是.NET Standard 2.0 I'm using Visual Studio 2022 and this is the first time I've run a Xamarin solution.我使用的是 Visual Studio 2022,这是我第一次运行 Xamarin 解决方案。

The nnn.Core project does not build and gives a series of identical compilation errors nnn.Core项目不构建并给出一系列相同的编译错误

CS0656 Missing compiler required member 'Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create' CS0656 缺少编译器所需的成员“Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create”

When I first ran into this error, I did some searching and discovered this post which states当我第一次遇到这个错误时,我做了一些搜索并发现了这篇文章,其中指出

To fix it I had to include I just had to include Microsoft.CSharp from Nuget.要修复它,我必须包含我只需要包含来自 Nuget 的 Microsoft.CSharp。

So, I opened the project's .csproj file, which is the file containing the line所以,我打开了项目的.csproj文件,该文件包含该行

<TargetFramework>netstandard2.0</TargetFramework>

I found the ItemGroup containing the PackageReference elements, so added我发现ItemGroup包含PackageReference元素,所以添加

<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />

Rebuilding the solution took the number of errors from ~9 to 4, but the same errors persist.重建解决方案将错误数量从 ~9 减少到 4,但同样的错误仍然存在。 What's strange is that they are just a subset of the original errors, as if only some lines in the .Core project were fixed by the package inclusion, and some were not.奇怪的是,它们只是原始错误的一个子集,就好像.Core项目中只有一些行被 package 包含修复了,而有些则没有。 Yet, all the lines throwing the build error are in the same project.然而,所有抛出构建错误的行都在同一个项目中。

The first line throwing the build error above is the assignment to a dymamic property (second line):上面抛出构建错误的第一行是对dymamic属性的赋值(第二行):

dynamic values = new JObject();
values.LANGUAGE = _localize.GetCurrentCultureInfo().TwoLetterISOLanguageName.ToUpper();

In fact, all the lines still throwing the error are the first line following the creation of a dynamic object, where a property is assigned.事实上,仍然抛出错误的所有行都是创建dynamic object 之后的第一行,其中分配了一个属性。

What am I missing to fix this?我缺少什么来解决这个问题?

EDIT编辑

Specifically, the Android project has a packages.config file which contains具体来说,Android 项目有一个packages.config文件,其中包含

<package id="Microsoft.CSharp" version="4.7.0" targetFramework="monoandroid90" />

The iOS project's packages.config file also has iOS项目的packages.config文件也有

<package id="Microsoft.CSharp" version="4.7.0" targetFramework="xamarinios10" />

A Xamarin.Forms project has not only one.csproj file.一个Xamarin.Forms的项目,不止一个.csproj文件。 For the share part which you have been added the nuget package Microsoft.CSharp into.对于您已添加 nuget package Microsoft.CSharp的共享部分。

For the other platforms' part, such as YourProjecName.Android , YourProjecName.iOS and YourProjecName.UWP part.对于其他平台的部分,例如YourProjecName.AndroidYourProjecName.iOSYourProjecName.UWP部分。 You can try the steps below to add the nuget package Microsoft.CSharp .您可以尝试以下步骤来添加 nuget package Microsoft.CSharp

Right click on the platform part project-> Select the Unload the project->Double click the platform part project-> Add the <PackageReference Include="Microsoft.CSharp" Version="4.7.0" />右击平台部分项目->Select 卸载项目->双击平台部分项目->添加<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />

  • Close and reopen Visual Studio.关闭并重新打开 Visual Studio。
  • If still broken, close solution, delete all.bin and.obj folders.如果仍然损坏,请关闭解决方案,删除所有 .bin 和 .obj 文件夹。 Try again.再试一次。

暂无
暂无

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

相关问题 缺少编译器所需的成员“microsoft.csharp.runtimebinder.binder.convert” - Missing compiler required member 'microsoft.csharp.runtimebinder.binder.convert' 如何修复“错误 CS0656:缺少编译器所需的成员‘Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create’” - How to fix "error CS0656: Missing compiler required member 'Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create'" NuGet软件包管理器:&#39;AutoMapper&#39;已经具有为&#39;Microsoft.CSharp&#39;定义的依赖项 - NuGet Package Manager: 'AutoMapper' already has a dependency defined for 'Microsoft.CSharp' 在 C# 中嵌入 IronPython 的问题(缺少编译器所需的成员“Microsoft.CSharp.RuntimeBinder.Binder.InvokeMember” - Problems embedding IronPython in C# (Missing Compiler required member 'Microsoft.CSharp.RuntimeBinder.Binder.InvokeMember' 无法识别Microsoft.CSharp参考 - Microsoft.CSharp reference not recognized ASP.NET Core 1.1 使用 C# 动态编译 缺少编译器需要成员 'Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create' - ASP.NET Core 1.1 compiling with C# dynamic Missing compiler required member 'Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create' C#Compiler-as-a-Service:Mono.CSharp与Microsoft.CSharp - C# Compiler-as-a-Service: Mono.CSharp vs Microsoft.CSharp 使用不是管理员组成员的用户登录时无法加载文件或程序集“Microsoft.CSharp” - Could not load file or assembly 'Microsoft.CSharp' when logged in with user which is not a member of administrator group Microsoft.CSharp库中的BadImageFormat异常 - BadImageFormat Exception at Microsoft.CSharp library 无法找到参考组件Microsoft.CSharp - Reference Component Microsoft.CSharp could not be found
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM