Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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).

EDIT:

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.

like image 291
Yorro Avatar asked Dec 25 '13 01:12

Yorro


3 Answers

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)

like image 103
Yorro Avatar answered Oct 11 '22 21:10

Yorro


you can delete the original DLLS and Uninstall the reinstall.

like image 1
allenChen Avatar answered Oct 11 '22 21:10

allenChen


Run the following from PCM, Package Manager Console:

Install-Package Unity.Mvc

This will give you the DLL Microsoft.Practices.Unity.Mvc where it is.

like image 1
Ogglas Avatar answered Oct 11 '22 21:10

Ogglas