[英]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.Android
, YourProjecName.iOS
和YourProjecName.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" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.