I am using Visual Studio 2013 update 2, and I am having some strange behavior.
If I run this program without the debugger, the program runs fine and completes execution. However, if I run the program with a debugger, it throws an exception on the string x = Json.Encode(m);
line
using System;
using System.Web.Helpers;
namespace JsonTesting
{
internal class Program
{
public class MyClass
{
public string Hello = "Hi!";
}
private static void Main(string[] args)
{
var m = new MyClass();
string x = Json.Encode(m);
Console.WriteLine(x);
}
}
}
This is the exception:
An unhandled exception of type 'System.TypeInitializationException': "The type initializer for 'System.Web.Helpers.Json' threw an exception."
The inner exception is: "Attempt by method 'System.Web.Helpers.Json..cctor()' to access method 'System.Web.Helpers.Json.CreateSerializer()' failed."
Why is the exception only thrown when using the debugger?