title: ViewModel Dispose not being called
body: <p>We are using Ninject with Caliburn.Micro to create a MVVM WCF Silverlight app.  The issue I am having is with the life cycle of my view models.</p>
  
  <p>I have created a simple ninject module to bind my view model and wcf client.</p>
  
  <pre><code>   public class IDCardModule : NinjectModule
     {
          public override void Load()
          {
              Bind&lt;IIdCardManagerClient&gt;().To&lt;IdCardManagerClient&gt;();
              Bind&lt;IDCard.SL.ViewModel.IIdCardViewModel&gt;().To&lt;IDCard.SL.ViewModel.IdCardViewModel&gt;();
          }
     }
  </code></pre>
  
  <p>In my IIdCardViewModel I have required it inherit from IDisposable, because I want to register and de-register for wcf events and some local unmanaged references.</p>
  
  <p>However, Dispose is never being called.</p>
  
  <p>I looked into adding a deactivation to call dispose like this:</p>
  
  <pre><code>Bind&lt;IDCardExclude.SL.ViewModel.IIdCardExclusionViewModel&gt;().To&lt;IDCardExclude.SL.ViewModel.IdCardExclusionViewModel&gt;().OnDeactivation(
                  m =&gt; m.Dispose());
  </code></pre>
  
  <p>But that forced me to add two things, an Unload override in my IDCardModule that retrieved the object and released it:</p>
  
  <pre><code>var releaseMe = this.Kernel.Get&lt;IIdCardViewModel&gt;();
  this.Kernel.Components.Get&lt;Ninject.Activation.Caching.ICache&gt;().Release(releaseMe);
  </code></pre>
  
  <p>and either .InThreadScope() or .InSingletonScope() to my Bind method in Load.</p>
  
  <p><strong>Is there an easier way to force a deactivation on a specific object?  Or should I look into another IOC framework?</strong></p>
  
  <p>I looked into IStartable and had similar issues.
  As well, I read in-depth <a href="http://kohari.org/2009/03/06/cache-and-collect-lifecycle-management-in-ninject-20/" rel="nofollow">Nate's article</a> where he has an activation block and wraps everything in a using statement.  My issue there is that my view model can be long running and I don't believe his solution will work here.  As well, having a special thread that sleeps and calls GC.Collect, doesn't smell right either.</p>