runtime icon indicating copy to clipboard operation
runtime copied to clipboard

Unhandled Exception: Cannot print exception string because Exception.ToString() failed.

Open jeffschwMSFT opened this issue 10 years ago • 6 comments

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

jeffschwMSFT avatar Apr 15 '16 16:04 jeffschwMSFT

Could this be the same as https://github.com/dotnet/coreclr/issues/3412, which was fixed in https://github.com/dotnet/coreclr/pull/3858 ?

stephentoub avatar Apr 15 '16 16:04 stephentoub

@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)?

adityamandaleeka avatar May 20 '16 23:05 adityamandaleeka

I tried with RC2 (2702 on Mac) and it still repros.

jeffschwMSFT avatar May 23 '16 16:05 jeffschwMSFT

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.

lucasgodshalk avatar May 26 '16 14:05 lucasgodshalk

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.

sergiy-k avatar Jun 08 '16 16:06 sergiy-k

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.

lucasgodshalk avatar Jul 13 '16 13:07 lucasgodshalk