title: How to reset all instances in IOC Container
body: <p>I have made an C# WPF Application using the <a href="http://www.galasoft.ch/mvvm/" rel="noreferrer">MVVM Light framework</a>. My Application uses the <code>ViewModelLocator</code> class to locate the viewmodels during runtime. The <code>ViewModelLocator</code> makes usage of the <code>SimpleIoc</code> class which also comes with the <a href="http://www.galasoft.ch/mvvm/" rel="noreferrer">MVVM Light framework</a>.</p>
  
  <p>Here is my scenario: 
  The user logs in an can use my application. On logout, i want to dispose/reset/recreate all viewmodel instances to provide a clean environment to the next user.</p>
  
  <p>I tried to implement the <code>Cleanup()</code> method in the <code>ViewModelLocator</code> class but it is not working.
  Not working means that the (second) user sees the data from the user who was logged in before.</p>
  
  <p>first try:</p>
  
  <pre><code>public static void Cleanup()
  {
     SimpleIoc.Default.Reset();
  }
  </code></pre>
  
  <p>second try:</p>
  
  <pre><code>public static void Cleanup()
  {
     SimpleIoc.Default.Unregister&lt;LoginViewModel&gt;();
     SimpleIoc.Default.Unregister&lt;TaskViewModel&gt;();
  
     SimpleIoc.Default.Register&lt;LoginViewModel&gt;();
     SimpleIoc.Default.Register&lt;TaskViewModel&gt;();
  }
  </code></pre>
  
  <p>third try (not what i want but it is a workaround):</p>
  
  <pre><code>public static void Cleanup()
  {
     // I implemented the ICleanup interface in my viewmodels
     // The cleanup method clears all my variables eg: myCollection.clear();
     SimpleIoc.Default.GetInstance&lt;LoginViewModel&gt;().Cleanup();
     SimpleIoc.Default.GetInstance&lt;TaskViewModel&gt;().Cleanup();
  }
  </code></pre>
  
  <p>How do i reset all instances in my <code>ViewModelLocator</code> class? I'm willing to use a more advanced Ioc Container if necessary.</p>