无法构建C#项目

Nic*_*zee 31 .net c# json dynamic


我有一些奇怪的问题.
使用此代码时,我无法构建,但它没有给我构建错误.

代码

public void myMethod()
{              
    //This returns a string in JSON format.
    var jsonResponse = myApi.ReadMobileDevice("1");


    dynamic dynamicJson= JsonConvert.DeserializeObject(jsonResponse);

    //THIS LINE BREAKS MY BUILD. NO BUILD ERRORS SHOWN
    var jValue = dynamicJson["general.display_name"];
}
Run Code Online (Sandbox Code Playgroud)

任何人都可以告诉我为什么我的构建制动,以及为什么没有显示构建错误?

UPDATE - 输出
*也将var更改为字符串

1>------ Build started: Project: Control, Configuration: Debug x86 ------
1>  Restoring NuGet packages...
1>  To prevent NuGet from downloading packages during build, open the Visual Studio Options dialog, click on the Package Manager node and uncheck 'Allow NuGet to download missing packages'.
1>  All packages listed in packages.config are already installed.
1>C:\ActacomProjects\DEV-Google\Control\ModifyService.svc.cs(563,28,563,40): error CS0656: Missing compiler required member 'Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create'
1>C:\ActacomProjects\DEV-Google\Control\Classes\DomainObjects\Schedules\HTTPSchedulesResponse.cs(41,34,41,36): warning CS0168: The variable 'Ex' is declared but never used
1>C:\ActacomProjects\DEV-Google\Control\Classes\DomainObjects\Schedules\HTTPSchedulesResponse.cs(87,30,87,32): warning CS0168: The variable 'Ex' is declared but never used
1>C:\ActacomProjects\DEV-Google\Control\ModifyService.svc.cs(1225,26,1225,45): warning CS0219: The variable 'recreateApplication' is assigned but its value is never used
1>C:\ActacomProjects\DEV-Google\Control\ModifyService.svc.cs(1809,71,1809,74): warning CS0168: The variable 'dnf' is declared but never used
1>C:\ActacomProjects\DEV-Google\Control\ModifyService.svc.cs(1813,54,1813,56): warning CS0168: The variable 'ex' is declared but never used
1>C:\ActacomProjects\DEV-Google\Control\ModifyService.svc.cs(5017,34,5017,36): warning CS0168: The variable 'Ex' is declared but never used
1>C:\ActacomProjects\DEV-Google\Control\ModifyService.svc.cs(5087,42,5087,44): warning CS0168: The variable 'Ex' is declared but never used
1>C:\ActacomProjects\DEV-Google\Control\ModifyService.svc.cs(5154,42,5154,44): warning CS0168: The variable 'Ex' is declared but never used
1>C:\ActacomProjects\DEV-Google\Control\ModifyService.svc.cs(5192,42,5192,44): warning CS0168: The variable 'Ex' is declared but never used
1>C:\ActacomProjects\DEV-Google\Control\ModifyService.svc.cs(5267,42,5267,44): warning CS0168: The variable 'Ex' is declared but never used
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Run Code Online (Sandbox Code Playgroud)

ami*_*ama 87

输出中有此错误:

缺少编译器需要成员'Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create'

您需要添加对DLL Microsoft.CSharp.dll的引用.

  • 我必须在xamarin.Forms项目中添加Nuget.CSharp作为项目目标.Net core 2.x和CSharp程序集无法显式添加到可移植项目中.工作. (6认同)
  • 我使用Sakthivel中相同的原因,将nuget中的Microsoft.CSharp添加到.net标准项目中,以解决此问题 (2认同)
  • 我添加了 Nuget Package Microsoft.CSharp,但我有同样的错误。 (2认同)

The*_*tor 15

与Saminathan S在接受的答案中的评论相似.如果您正在使用.NETStandard项目(在我的情况下是NETStandard 2.0),您需要从NuGet添加Microsoft.CSharp而不是作为参考来解决此构建错误.我在Mac上使用Visual Studio社区.


Ada*_*unj 5

快速解决。

右键单击Packages> Add NuGet Packages...>Microsoft.CSharp

这对我有用。[Mac,Visual Studio 2017 社区]