Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 533
recursive Avatar asked Sep 02 '16 21:09

recursive


People also ask

Can you reference .NET core from .NET standard?

NET Standard 2.0. That means you can reference the logic library not only from a . NET Core app, but also from an app built for . NET Framework or Xamarin.

Can I reference .NET Framework .NET 6?

Yes, you can load . NET Framework assemblies into . NET Core 5 and 6.

How do you target NET 6?

To set target . NET runtime version to 6.0, enter <TargetFramework>net6. 0</TargetFramework> version in project's .

Is .NET 6 compatible with .NET standard 2?

Targeting Netstandard 2.0 or lower means you'll be able to run on NET 5/6/7 or NET Framework 4. Targeting Netstandard 2.1 means you'll be requiring installation of NET 5/6/7 to run and only be compatible with NET 5/6/7. If you target NET Framework directly, you are only writing legacy NET windows code.


1 Answers

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

like image 172
Set Avatar answered Oct 02 '22 18:10

Set