title: CastException after recompile when using objects stored in SQL session database
body: <p>To maintain the sessions after a recompile I'm using SQLServer for storing the sessionstate. This works very well as long as I'm not storing custom objects. When the trying to use a custom object after a recompile that has been stored in the session I get the following error:</p>
  
  <pre><code>[A]MyObject cannot be cast to [B]MyObject. 
  Type A originates from 'App_Code.9qazkuv_, Version=1.3.0.0, Culture=neutral, PublicKeyToken=null' 
      in the context 'Default' at location 
      'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files
          \root\26676eb7\92c7e946\App_Code.9qazkuv_.dll'. 
  Type B originates from 'App_Code.jndyusrx, Version=1.3.0.0, Culture=neutral, PublicKeyToken=null' 
      in the context 'Default' at location 
      'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files
          \root\26676eb7\92c7e946\App_Code.jndyusrx.dll'.
  </code></pre>
  
  <p>I have been strugling with this bug for months and the only solution I've found so far is to put the object in a dll file. In some cases this is not so easy to do though. There has to be an easier method to get around this problem. Any suggestions?</p>
  
  <p>What also is strange is that the bug is not easy to reproduce. I've tried to copy my site to a testenviroment to experiement with the problem, but I'm not able to reproduce the error in the testenviroment which is on the same server. And on localhost the problem dosent occur at all. </p>