Considering
public class a : IDisposable
{
public static int counter;
public a()
{
counter++;
}
~a()
{
counter--;
}
public void Dispose()
{
}
}
With registration:
application_container = new WindsorContainer( );
application_container.Register( Component.For<a>( ).ImplementedBy<a>( ).LifeStyle.PerWebRequest );
Own things in web.config:
<add name="PerRequestLifestyle"
type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule,
Castle.MicroKernel"/>
Using a version of the castle built from SVN. With webpage code:
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
GC.Collect( 2 );
var a = Global.application_container.Resolve<Global.a>();
Response.Write( Global.a.counter.ToString() );
}
}
I get that ~ a () is not being called, and the RedGate profiler shows that a is not a collection, the link to it is stuck in AllComponentsReleasePolicy.instance2burden.
I am not the first to encounter this problem
http://groups.google.com/group/castle-project-users/browse_thread/thread/bd287dd66b3a9d64/f48d740621508c64?lnk=gst&q=PerWebrequest#f48d740621508c64
source
share