Luca Morelli Luca Morelli - 1 year ago 245
C# Question

cannot use dynamic type with vnext core

I need to read and save a JSON file inside an ASP.NETt vNext app, and I would like to use a

variable to store the value loaded using, but when I go to compile I received this error message:

ASP.NET Core 5.0 error CS1980: Cannot define a class or member that utilizes
because the compiler required type
cannot be found. Are you missing a reference?

How can solve this? If I use
, can I run an application using ASP.NET core?

Answer Source

You need to include the packages Microsoft.CSharp and System.Dynamic.Runtime for the aspnetcore50 framework.

This seems to work for me with CoreCLR version 1.0.0-beta1:

´╗┐using Newtonsoft.Json.Linq;
using System;

namespace DynamicTest
    public class Program
        public void Main(string[] args)

            dynamic dobject = JObject.Parse("{number:1000, str:'string', array: [1,2,3,4,5,6]}");


The project.json

    "version": "1.0.0-*",
    "dependencies": {
        "Newtonsoft.Json" :  "6.0.7"
    "commands": { 
        "run" : "run"
    "frameworks" : {
        "aspnet50" : { },
        "aspnetcore50" : { 
            "dependencies": {
                "System.Console": "4.0.0-beta-22231",
                "System.Dynamic.Runtime": "4.0.0-beta-22231",
                "Microsoft.CSharp": "4.0.0-beta-22231"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download