[英]ASP.NET Core 1.1 compiling with C# dynamic Missing compiler required member 'Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create'
I'm using Visual Studio 2017 RC and started a new ASP.NET Core project targeting the full .NET Framework.我正在使用 Visual Studio 2017 RC 并启动了一个新的 ASP.NET 核心项目,目标是完整的 .NET 框架。
This line of code will not compile.这行代码不会编译。
dynamic handler = _container.GetService(handlerType);
if (handler == null) _logger.LogError("Can't find handler to handle " + cmd.GetType().Name);
I get the following error我收到以下错误
CS0656 Missing compiler required member 'Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create'
After some Googling it looks like this is because I'm missing the Microsoft.CSharp Assembly.经过一些谷歌搜索后,它看起来是因为我缺少 Microsoft.CSharp 程序集。 There are plenty of people who have stumbled into his issue but not seemingly with .NET Core 1.1.
有很多人偶然发现了他的问题,但似乎不是 .NET Core 1.1。
So I did this Install-Package Microsoft.CSharp
and got version 4.3.0.所以我做了这个
Install-Package Microsoft.CSharp
并获得了 4.3.0 版。 My project still won't build.我的项目仍然无法构建。
If I add an Assembly Reference to Microsoft.CSharp (the GAC'd version) then it Compiles and runs.如果我将程序集引用添加到 Microsoft.CSharp(GAC 版本),那么它会编译并运行。
Is this a Bug?这是一个错误吗? I would have expected the NuGet package to fix this?
我本来希望 NuGet package 能解决这个问题?
只需添加 Microsoft.CSharp.dll 的引用,您的错误将被删除。
I faced this problem.我遇到了这个问题。 I resolved this problem for me.
我为我解决了这个问题。 You must install
Microsoft.CSharp
library to your solution from nuget.您必须从 nuget 将
Microsoft.CSharp
库安装到您的解决方案中。
You can use Package Manager Console for install Microsoft.CSharp .您可以使用包管理器控制台安装Microsoft.CSharp 。 For example If you want install Microsoft.CSharp 4.7.0 version, you must run this command on the Package Manager Console:
例如,如果要安装 Microsoft.CSharp 4.7.0 版本,则必须在包管理器控制台上运行此命令:
Install-Package Microsoft.CSharp -Version 4.7.0
Nuget link: Microsoft.CSharp Nuget 链接: Microsoft.CSharp
There was a similar problem.有一个类似的问题。 I wanted to create a NetStandartd 2.0 library for the NetFramework 4.6.2 environment that
uses a dynamic object
and got the error "Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create".我想为
uses a dynamic object
的 NetFramework 4.6.2 环境创建一个 NetStandartd 2.0 库,但出现错误“Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create”。 This error is caused by the absence of the Microsoft.CSharp library
.此错误是由于缺少
of the Microsoft.CSharp library
引起的。 By correcting.csproj
file I was able to make the correct linking
:通过
correcting.csproj
文件,我能够to make the correct linking
:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0;net462</TargetFramework>
<DependsOnNETStandard>netstandard2.0</DependsOnNETStandard>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
</Project>
I was getting this problem when trying to implicitly casting type dynamic<\/code> to
object<\/code> .
我在尝试将类型
dynamic<\/code>隐式转换为
object<\/code>时遇到了这个问题。
var output = new Dictionary<string, object>(); // <- object
foreach(var attribute in attributes)
{
var attr = attribute as IEntityAttribute<dynamic>; // <- dynamic
if (attr != null)
{
output.Add(attr.GetType().Name, attr.Value);
}
}
return output;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.