简体   繁体   中英

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 . I'm using Visual Studio 2022 and this is the first time I've run a Xamarin solution.

The nnn.Core project does not build and gives a series of identical compilation errors

CS0656 Missing compiler required member '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.

So, I opened the project's .csproj file, which is the file containing the line

<TargetFramework>netstandard2.0</TargetFramework>

I found the ItemGroup containing the PackageReference elements, so added

<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. 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. 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):

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.

What am I missing to fix this?

EDIT

Specifically, the Android project has a packages.config file which contains

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

The iOS project's packages.config file also has

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

A Xamarin.Forms project has not only one.csproj file. For the share part which you have been added the nuget package Microsoft.CSharp into.

For the other platforms' part, such as YourProjecName.Android , YourProjecName.iOS and YourProjecName.UWP part. You can try the steps below to add the 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" />

  • Close and reopen Visual Studio.
  • If still broken, close solution, delete all.bin and.obj folders. Try again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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