title: ExecutionEngineException when calling method on decoupled WMI provider
body: <p>I've run into a problem where calling a method on a decoupled WMI provider (developed using the WMI Provider Extensions in .NET 3.5) throws an ExecutionEngineException when running more than one instance of my application. Has anyone run into this limitation before or am I doing something wrong?</p>
  
  <p>I created a (simple) WMI provider and publish it the ctor of a (WinForms) form. If you run one instance of the application everything works great; however, if you run multiple instances of the application, one will crash when calling a WMI method.</p>
  
  <p>Here's the WMI provider class (installer class, and form that publishes the WMI object) It's roughly based on <a href="http://www.codeproject.com/KB/system/WMIProviderExtensions.aspx" rel="nofollow noreferrer">this article</a>.</p>
  
  <pre><code>[assembly: WmiConfiguration(@"root\foo", HostingModel = ManagementHostingModel.Decoupled)]    
  
  [ManagementEntity(Singleton = false)]
  [ManagementQualifier("Description", Value = "Obtain processor information.")]
  public class Test
  {
      private readonly int _id;
      private int _value;
  
      [ManagementBind]
      public Test([ManagementName("Id")] int id)
      {
          _id = id;
      }
  
      [ManagementKey]
      public int Id
      {
          get { return _id; }
      }
  
      [ManagementProbe]
      [ManagementQualifier("Description", Value = "The number of processors.")]
      public int Value
      {
          get { return _value; }
      }
  
      [ManagementTask]
      public void Increment()
      {
          _value++;
      }
  
      public static Test Create()
      {
          int id = Process.GetCurrentProcess().Id;
          var wmi = new Test(id);
          return wmi;
      }
  }
  
  /// &lt;summary&gt;
  /// This installer is for the WMI Provider Extensions for .NET 3.5 support.
  /// &lt;/summary&gt;
  public class LearningWmiManagementInstaller : DefaultManagementInstaller 
  {}
  
  public partial class Form1 : Form
  {
      private Test _pi;
  
      public Form1()
      {
          InitializeComponent();
  
          _pi = Test.Create();
          InstrumentationManager.Publish(_pi);
      }
  
      protected override void OnClosed(EventArgs e)
      {
          base.OnClosed(e);
          InstrumentationManager.Revoke(_pi);
      }
  }
  </code></pre>
  
  <p>Of course, I use installutil to run the WMI installer class. Next, startup two instances of the application. If you call the "Increment" WMI [ManagementTask] method using the wmic tool on one of the processes then the other will crash (oddly, not the one you invoke). </p>
  
  <pre><code>wmic /namespace:\\root\foo path Test.Id=&lt;process-id&gt; call increment
  </code></pre>
  
  <p>Any suggestions would be greatly appreciated.</p>