让 SNAP(AOP)、NInject 和 ASP.Net MVC 3 协同工作
有谁得到了与 MVC 3 和 Ninject 一起使用的 SNAP AOP 框架吗?
使用 NuGet 将 Snap 添加到 MVC 3 项目时给出的示例并不特别适用于之前添加的 NInject 包。我试图让它基于正常的 NInject 方法工作,但就是无法让它真正拦截!
任何人都可以展示如何在代码中执行此操作吗?
Has anyone got the SNAP AOP framework working with MVC 3 and Ninject.
The samples given when adding Snap using NuGet to an MVC 3 project don't specifcally work well with a previously added NInject package. I have tried to get it working based on the normal NInject approach but just cannot get it to actually intercept!
Can anyone show how to do this in code please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通过 NuGet 使用最新版本的 Ninject 解决了这个问题,现在它在 MVC3 应用程序的新 AppStart 文件夹中添加了一个类调用 NinjectMVC3。
我使用的代码如下:
在自动创建的 NinjectMVC3.cs CreateKernel() 方法中:-
我还在 RegisterServices() 方法中为各种注入目标连接了 Ninject。
接下来,我将 SNAP.Ninject 添加到 MVC 3 应用程序时由 NuGet 生成的示例代码,将其重命名为 NinjectAOP.cs 并使其如下所示:
我还需要为 Ninject 执行程序集绑定重定向,如下所示,因为 Ninject 某处存在程序集版本冲突:
我希望这对某人有帮助。
我邀请任何人看看,看看他们是否可以改进这一点。
I figured it out with the latest version of Ninject through NuGet which now adds a class call NinjectMVC3 in a new AppStart folder in the MVC3 application.
The code I used is as folows:
In the automatically created NinjectMVC3.cs CreateKernel() method:-
I also wired up Ninject for the various injection targets in RegisterServices() method.
Next I took the sample code generated by NuGet when adding SNAP.Ninject to the MVC 3 application, renamed it NinjectAOP.cs and made it look like this:
I also needed to do an assembly binding redirect for Ninject as follows because there is an assembly version conflict somewhere for Ninject:
I hope this helps someone.
I invite anyone to have a look and see if they can improve this please.