Unhandled Exception: Cannot print exception string because Exception.ToString() failed.
While trying to get Newtonsoft.json working, I noticed an error with unhandled exception messages.
Dotnet --info .NET Command Line Tools (1.0.0-rc2-002394)
Product Information: Version: 1.0.0-rc2-002394 Commit Sha: 3a423b1080
Runtime Environment: OS Name: Windows OS Version: 10.0.10586 OS Platform: Windows RID: win10-x64
Repo: dotnet new notepad project.json { "version": "1.0.0-*", "compilationOptions": { "emitEntryPoint": true }, "dependencies": { "Microsoft.NETCore.App": { "type": "platform", "version": "1.0.0-rc2-3002374" }, "Newtonsoft.json": "8.0.3" }, "frameworks": { "netcoreapp1.0": { "imports": ["dnxcore50", "portable-net45+win8"] } } }
dotnet restore
notepad program.cs using System;
namespace ConsoleApplication { public class Program { public static void Main(string[] args) { Newtonsoft.Json.Linq.JObject obj = Newtonsoft.Json.JsonConvert.DeserializeObject<Newtonsoft.Json.Linq.JObject>(@"{Name:""Bob""}");
System.Console.WriteLine(obj["Name"]);
Console.WriteLine("Hello World!");
}
}
} dotnet build dotnet run
Actual: Fails with a filenotfound exception which produces this unhandled exception message: Unhandled Exception: Cannot print exception string because Exception.ToString() failed.
Expected: Json should be functional
Could this be the same as https://github.com/dotnet/coreclr/issues/3412, which was fixed in https://github.com/dotnet/coreclr/pull/3858 ?
@jeffschwMSFT I agree with @stephentoub that dotnet/coreclr#3858 should have fixed this. Can we close this issue (unless you're still running into this problem)?
I tried with RC2 (2702 on Mac) and it still repros.
I have a very similar app using newtonsoft.json and it repros, I'm on build 2872 of the cli (win-64). Removing json.net and throwing a different exception works as expected.
This was fixed by https://github.com/dotnet/coreclr/pull/3858 in master but I don't think it was ported to RC2. It should fixed for v1.0 though.
Just a friendly reminder to make sure your project is updated use core 1.0, otherwise the error will keep happening. That caught me for a moment.