Thursday, May 2, 2013

A very short note on migrating from Spring.NET 1.1.x to 1.3.x or 2.x

I used to have something like this in my code for getting the Spring.NET context:

using (IApplicationContext ctx = ContextRegistry.GetContext())
            {
                
                traceListener =
                    (TraceListener) ctx.GetObject(initializationData);
            }

After upgrade to 1.3.2 I was rewarded with:

No context registered under name '{0}'. Use the 'RegisterContext' method or the 'spring/context' section from your configuration file.

Short investigation showed Spring.NET is not then getting the context initiated again if it was removed (I didn’t realize that) by using/Dispose pattern.

I’ll let it to the conscious of spring.NET authors to decide if this is a correct implementation of disposal pattern from their side, corrected line of code now looks just like:

traceListener =
                    (TraceListener) ctx.GetObject(initializationData);

No comments: