title: Type Initializer Error in WPF
body: <p>My WPF application was compiling fine </p>
  
  <p>but after I added a Label element, </p>
  
  <pre><code>&lt;Label Content="Time Remaining:" Foreground="White" Grid.Row="0" Grid.Column="1" VerticalAlignment="Bottom" HorizontalAlignment="Right"/&gt;
  </code></pre>
  
  <p>it shows</p>
  
  <blockquote>
    <p>The type initializer for 'System.Windows.Media.FontFamily' threw an
    exception</p>
  </blockquote>
  
  <p>on compilation. It works if I remove the Label element.</p>
  
  <p>I searched for a while and tried using this line of code</p>
  
  <pre><code> Environment.SetEnvironmentVariable("windir", Environment.GetEnvironmentVariable("SystemRoot"));
  </code></pre>
  
  <p>but still it shows the exception.</p>
  
  <p><strong>EDIT:</strong> I deleted all the fonts in my computer except the protected fonts and it solved the problem.</p>