asp.net mvc 4 - Unity.MVC4 Doesn't Dispose() -
i've installed nuget unity.mvc4 package http://nuget.org/packages/unity.mvc4/ , have hooked same if using unity.mvc3 package.
my dependencies getting resolved correctly, when using hierarchicallifetimemanager, object's dispose() method not called @ end of request.
i've set simple project using unity.mvc3 , unity.mvc4, exact same bootstrapper.cs code in both projects. on mvc3 version, dispose() called; on mvc4 version, not.
i'm registering type so
container.registertype<itest, test>(new hierarchicallifetimemanager()); with simple test class
public interface itest { void foo(); } public class test : idisposable, itest { public test() { } public void foo() { } public void dispose() { } } i don't think i'm doing incorrectly, there appears bug in unity.mvc4 package.
if using package, i'm curious how got work.
the best solution issue upgrade unity3 , install unity bootstrapper asp.net mvc package. bootstrapper package includes perrequestlifetimemanager should used in place of hierarchicallifetimemanager. once integration complete, dispose() called @ end of every http request expected.
note newest unity documentation suggests perrequestlifetimemanager should not used @ unless absolutely necessary. (i believe, however, still needed in cases - example, want share dbcontext across objects used during single request.)
with solution, unity.mvc4 no longer needed , can uninstalled.
Comments
Post a Comment