Knagis/CommonMark.NET

ASPNET Core 1.1 - You must add a reference to assembly 'mscorlib

Closed this issue · 3 comments

arruw commented
using CommonMark;

// ...

var markdown = "";
var html = CommonMark.CommonMarkConverter.Convert(markdown);
//                                        ~~~~~~~

I'm getting following error:

The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'. [netcoreapp1.1]

I'am using ASP.NET Core 1.1 SDK (1.0.0-preview2-1-003177)

{
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.1.0",
      "type": "platform"
    },
    "Microsoft.AspNetCore.Diagnostics": "1.1.0",
    "Microsoft.AspNetCore.Mvc": "1.1.0",
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.1.0-preview4-final",
      "type": "build"
    },
    "Microsoft.AspNetCore.Routing": "1.1.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
    "Microsoft.AspNetCore.StaticFiles": "1.1.0",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0",
    "Microsoft.Extensions.Configuration.Json": "1.1.0",
    "Microsoft.Extensions.Configuration.CommandLine": "1.1.0",
    "Microsoft.Extensions.Logging": "1.1.0",
    "Microsoft.Extensions.Logging.Console": "1.1.0",
    "Microsoft.Extensions.Logging.Debug": "1.1.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.1.0",
    "CommonMark.NET": "0.9.1",
    "Newtonsoft.Json":"9.0.1"
  },

  "tools": {
    "BundlerMinifier.Core": "2.2.306",
    "Microsoft.AspNetCore.Razor.Tools": "1.1.0-preview4-final",
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final",
    "Microsoft.DotNet.Watcher.Tools": "1.1.0-preview4-final"
  },

  "frameworks": {
    "netcoreapp1.1": {
      "imports": [
        "dotnet5.6",
        "portable-net45+win8"
      ]
    }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "**/*.cshtml",
      "appsettings.json",
      "web.config"
    ]
  },

  "scripts": {
    "precompile": [ "dotnet bundle" ],
    "prepublish": [ "bower install" ],
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  },

  "tooling": {
    "defaultNamespace": "dns"
  }
}

OK, I started to migrate the .NET Core project from DNX to the new format, hopefully it will resolve this issue as well..

By the way, you are using a rather old version of CommonMark.NET.

arruw commented

After changing framework part to this, it works. What it the latest version, I'm using latest that VSCode intelisense offers to me?

"frameworks": {
    "netcoreapp1.1": {
      "imports": [
        "aspnetcore50"
      ]
    }
  }

The latest is 0.14.0 (see https://www.nuget.org/packages/CommonMark.NET/)

I suspect that the issue was because of the fact in 0.9.1 there was no assembly marked for .NET Standard 1.0, instead only for the dnxcore50 framework. If I am reading the docs correctly, the support for dnxcore50 packages is added to project with the import statement you mentioned.

With the latest version there should be no need for that import.