我正在尝试在一个以C# .net core为目标的应用程序中使用一个dynamic
变量,该应用程序针对.net standard 1.6。(平台?库?框架?元框架?) 我最初在一个真实的应用程序中遇到了这个问题,但我已经将其简化为一个最小的复现。
project.json
{
"version": "1.0.0-*",
"buildOptions": { "emitEntryPoint": true },
"dependencies": { "NETStandard.Library": "1.6.0" },
"frameworks": {
"netstandard1.6": { "imports": "dnxcore50" }
},
"runtimes": { "win10-x64": {} }
}
程序.cs
using System;
public class Program {
public static void Main(string[] args) {
dynamic hello = "hello world";
Console.WriteLine(hello);
}
}
当我尝试构建这个时,Console.WriteLine(hello);
出现构建错误,指出:
CS0656 缺少必需的编译器成员'Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create'
在面向netstandard 1.6的应用程序中是否可能使用dynamic
变量?如何做到?
netcoreapp1.0
(也支持netstandard 1.6
)来进行目标定位可以修复该错误。这很奇怪。 - krontogiannis