title: LitJSON error in powershell
body: <p>I'm trying to use Leonardo B's <a href="https://github.com/lbv/litjson" rel="nofollow noreferrer">litjson</a> library from PowerShell.  The entry point to the library I need to use is a static method.  I can load the assembly with add-type, no problem.  Trying to use the static method though gives this error:</p>
  
  <pre><code>PS C:\Users\david&gt;[litjson.jsonmapper]::toobject("{`"foo`":`"bar`"}")
  format-default : The JsonData instance has to be initialized first
      + CategoryInfo          : NotSpecified: (:) [format-default], InvalidOperationException
      + FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.PowerShell.Commands.FormatDefaultCommand
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/XyFyV.png" alt="The JsonData instance has to be initialized first"></p>
  
  <p>I though that what was happening was that the <a href="https://github.com/lbv/litjson/blob/89051bc46b52109550cb1422716e95f9c30400c8/src/LitJson/JsonMapper.cs#L135" rel="nofollow noreferrer">static constructor</a> for this class didn't run, but Lars Truijens corrected that misunderstanding.  The error is an exception from the JsonData class.  Although the same line of code works correctly in VS2012 (targeting .net 3.5) it won't run in powershell.</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>This unit test passes in visual studio 2012:</p>
  
  <pre><code>using System;
  using Microsoft.VisualStudio.TestTools.UnitTesting;
  using LitJson;
  
  namespace litjsonTest
  {
      [TestClass]
      public class TestJsonMapper
      {
          [TestMethod]
          public void TestMethod1()
          {
              var obj = LitJson.JsonMapper.ToObject("{\"foo\":\"bar\"}");
              Assert.IsNotNull(obj);
          }
      }
  }
  </code></pre>