Search code examples
c#roslyn.net-core.net-standard-1.6

Dynamic reference in a .net core app targeting net standard 1.6?


I'm trying to use a dynamic variable in a C# .net core app that's targeting .net standard 1.6. (platform? library? framework? meta-framework?) I first encountered this problem in a real application, but I have reduced it to a minimal reproduction.

project.json

{
    "version": "1.0.0-*",
    "buildOptions": { "emitEntryPoint": true },
    "dependencies": { "NETStandard.Library": "1.6.0" },
    "frameworks": {
        "netstandard1.6": { "imports": "dnxcore50" }
    },
    "runtimes": { "win10-x64": {} }
}

Program.cs

using System;

public class Program {
    public static void Main(string[] args) {
        dynamic hello = "hello world";
        Console.WriteLine(hello);
    }
}

When I try to build this, I'm getting a build error on Console.WriteLine(hello); saying this.

CS0656 Missing compiler required member 'Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create'

Is it possible to use dynamic variables in an application targeting netstandard 1.6? How?


Solution

  • Add System.Dynamic.Runtime and Microsoft.CSharp as dependencies.