Windsor在MVC 3中解析IViewEngine

发布于 2025-01-04 23:19:35 字数 546 浏览 3 评论 0原文

使用 Windsor 2.5.1.0 将其放在 Global.asax 中

_windsor.Register(
    Component.For<IViewEngine>().ImplementedBy<RazorViewEngine>(),
);

紧接着执行此操作时:

IViewEngine tt2 = _windsor.Resolve<IViewEngine>();
int count = ((RazorViewEngine) tt2).ViewLocationFormats.Length;

count 变量为 0,但使用此:

IViewEngine tt2 = new RazorViewEngine();
int count = ((RazorViewEngine) tt2).ViewLocationFormats.Length;

它是 4,这是默认值。我不明白为什么温莎实例返回零?

有人有建议吗?

Have this in Global.asax using windsor 2.5.1.0

_windsor.Register(
    Component.For<IViewEngine>().ImplementedBy<RazorViewEngine>(),
);

When executing this right after:

IViewEngine tt2 = _windsor.Resolve<IViewEngine>();
int count = ((RazorViewEngine) tt2).ViewLocationFormats.Length;

The count variable is 0, but with this:

IViewEngine tt2 = new RazorViewEngine();
int count = ((RazorViewEngine) tt2).ViewLocationFormats.Length;

It is 4, which is the default. I cannot see why the windsor instance is returning zero?

Anyone have a suggestion?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

°如果伤别离去 2025-01-11 23:19:35

我在寄存器之前:

container.Kernel.Resolver.AddSubResolver(new ArrayResolver(container.Kernel, true));

这给出了错误。沃

I had before the registers:

container.Kernel.Resolver.AddSubResolver(new ArrayResolver(container.Kernel, true));

Which gave the error. Wo

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文