Yorro Yorro - 8 hours ago 2
C# Question

Can't find PerRequestLifetimeManager class in Unity.MVC4 or Unity(3.0)

I am trying to locate PerRequestLifetimeManager. In MSDN, it says that it is part of the Unity 3 assembly.

I've installed Unity.Mvc4 via Nuget. The package.config says I am using Unity 3.0:

enter image description here

The Microsoft.Practices.Unity.dll says I am using Unity 3.0

enter image description here

I looked inside the DLL using object browser, and the PerRequestLifetimeManager is no where to be found.

Am I missing something here?

If someone will suggest an alternative class, I am planning to use a custom PerRequestLifetimeManager found here (if I am unable to find the class).


I've uninstalled Unity.Mvc4 and directly installed the Unity3.0 in the package console, here is what I got:

PM> Install-Package Unity -version 3.0.1304.1
'Unity 3.0.1304.1' already installed.
Successfully added 'Unity 3.0.1304.1' to RedLions.Presentation.Web.

I still can't find the PerRequestLifetimeManager class, even in the official library.


It seems not good to answer my own question when I just instead did it on my own. I can no longer delete my question.

Anyway, here was my solution.

I went straight to the source code of Unity, I found out that the class does exist in the same namespace but not in the same assembly. PerRequestLifetimeManager is in Microsoft.Practices.Unity.Mvc

enter image description here

I checked MSDN and it did say that its in a different DLL, which I failed to notice. Sorry about that.

It is not part of the Unity package in nuget, but in a different package in Nuget (Unity.Mvc), so here it is: http://www.nuget.org/packages/Unity.Mvc/

I decided to dump Unity.Mvc4 as it is no longer needed, everything is already in the Unity.Mvc. (App_Start/UnityConfig.cs)