gpt4 book ai didi

c# - 在 Unity.MVC4 或 Unity(3.0) 中找不到 PerRequestLifetimeManager 类

转载 作者:可可西里 更新时间:2023-11-01 08:53:00 25 4
gpt4 key购买 nike

我正在尝试定位 PerRequestLifetimeManager。在 MSDN 中,it says that it is part of the Unity 3 assembly.

我已经通过 Nuget 安装了 Unity.Mvc4。 package.config 说我正在使用 Unity 3.0:

enter image description here

Microsoft.Practices.Unity.dll 说我正在使用 Unity 3.0

enter image description here

我使用对象浏览器查看了 DLL,找不到 PerRequestLifetimeManager

我是不是漏掉了什么?

如果有人会建议替代类,我打算使用自定义的 PerRequestLifetimeManager 找到 here (如果我找不到类(class))。

编辑:

我卸载了Unity.Mvc4,直接在package console安装了Unity3.0,结果如下:

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.

即使在官方库中,我仍然找不到 PerRequestLifetimeManager 类。

最佳答案

当我只是自己回答问题时,似乎不太好回答我自己的问题。我不能再删除我的问题。

无论如何,这是我的解决方案。

我直接去Unity的源代码,我发现这个类确实存在在同一个命名空间中,但不在同一个程序集中。 PerRequestLifetimeManager 位于 Microsoft.Practices.Unity.Mvc

enter image description here

我检查了 MSDN,它确实说它在不同的 DLL 中,但我没有注意到。对此感到抱歉。

它不是 nuget 中 Unity 包的一部分,而是在 Nuget (Unity.Mvc) 中的另一个包中,所以这里是:http://www.nuget.org/packages/Unity.Mvc/

我决定转储 Unity.Mvc4,因为不再需要它,一切都已经在 Unity.Mvc 中了。 (App_Start/UnityConfig.cs)

关于c# - 在 Unity.MVC4 或 Unity(3.0) 中找不到 PerRequestLifetimeManager 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20768406/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com