title: Why is the Destructor not being called?
body: <p>I have a very interesting scenario where I would like a class to inform another entity it has been destroyed; however, its not doing what I want it too.</p>
  
  <h2>The Problem</h2>
  
  <p>The deconstructor, for some reason does not do what its supposed to do.</p>
  
  <h2>The Question</h2>
  
  <p>Why is the destructor not being invoked and make sure that it does do its necessary clean up.</p>
  
  <h2>The Code</h2>
  
  <p>So here we have the informer ~</p>
  
  <pre><code>class Connection 
  {
     public const int Port = 50000;// Can be any range between 49152 and 65536
  
      //Teh Constructor
      public Boolean Connect()
      {
          //SetInformation
          Information.Id = 545;
  
          using (var WebServ = new ClientSDKSoapClient("ClientSDKSoap"))
          {
              ContinueConnection.WaitOne();
              WebServ.ClientLogin(Information);
          }
          return true;
      }
  
      ~Connection()
      {
          using (var WebServ = new ClientSDKSoapClient("ClientSDKSoap"))
          {
              WebServ.ClientLogout(Information);
          }
      }
  }
  </code></pre>
  
  <h2>Additional Information</h2>
  
  <p>I want the web service to record if the Connection Class is destroyed for any given reason.
  When the client is connecting, it works perfectly. The Web Service records every method called from it. If I call ClientLogout explicitly, it will work.</p>
  
  <p>I am aware I can implement IDisposable; however, this object is not intended to be used within the lifetime of one method. In fact, its intended for use for the entire duration of the program and the failure of this object basically results in the failure of the entire project. (Although I suppose main IS a method...)</p>
  
  <p>I need to release a network connection; however, its not in this program, its in another program and unless ClientLogout is called, it won't be released.  </p>
  
  <h2>My Research</h2>
  
  <p>Microsoft <a href="http://msdn.microsoft.com/en-us/library/66x5fx1b.aspx" rel="nofollow">says</a> that you should use the deconstructor for the release of unmanaged resources making an explicit reference to network connections. This ones got my quite stumped.</p>