title: C# WPF with CLR throw exception
body: <p>I am creating WPF in Visual Studio 2015, I have a CLR class.</p>
  
  <p>Just very straightforward, I open up Visual Studio 2015 and create the CLR (Class Library), and build it.
  And then, I create a WPF Application, I added the CLR as a reference in my WPF project. I tried to build both projects in AnyCPU.</p>
  
  <p><a href="https://i.stack.imgur.com/dOFiH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dOFiH.png" alt="enter image description here"></a></p>
  
  <pre><code>// TestCLR.h  
  #pragma once
  
  using namespace System;
  
  namespace TestCLR {
  
      public ref class TestWrapper
      {
      public:
          TestWrapper() {}
          ~TestWrapper() {}
  
          // TODO: Add your methods for this class here.
      };
  }
  
  
  // TestCLR.cpp
  // This is the main DLL file.
  #include "stdafx.h"
  #include "TestCLR.h"
  </code></pre>
  
  <hr>
  
  <pre><code>// in my MainWindow.xaml.cs
  namespace TestWpf
  {
      /// &lt;summary&gt;
      /// Interaction logic for MainWindow.xaml
      /// &lt;/summary&gt;
      public partial class MainWindow : Window
      {
          private TestWrapper test;
  
          public MainWindow()
          {
              InitializeComponent();
  
              // when uncomment the following line, an exception is thrown
              test = new TestWrapper();
          }
      }
  }
  </code></pre>
  
  <p>When I run the WPF program, it throws an exception
  <a href="https://i.stack.imgur.com/ewtex.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ewtex.png" alt="enter image description here"></a></p>
  
  <p>Am I missing some critical info/settings for WPF that need to work with CLR?</p>