使用 Unity 和 VirtualMethodInterceptor 进行异常处理

发布于 2024-12-05 20:31:30 字数 590 浏览 5 评论 0原文

我已经使用企业库配置器在应用程序中配置了异常处理(简单:为所有异常添加了新策略,添加了传递到日志块的处理程序。然后将其写入 Windows 事件系统)

但是,当我使用 VirtualMethodInterceptor 实例化对象时- 它不处理任何异常。当我切换到透明代理拦截器时 - 它起作用了。

我使用代码来创建这样的对象:

_container.RegisterType<T, TK>(
            new ContainerControlledLifetimeManager(),
            new InterceptionBehavior<PolicyInjectionBehavior>(), 
            new Interceptor<VirtualMethodInterceptor>())

有什么问题吗? TransparentProxyInterceptor速度慢,最好不要使用。

我使用 Unity 5.0

更新版。忘了说:我正在使用一个属性来指示应该处理的方法: [ExceptionCallHandler("策略")]

I've configurated exception handling in app using Enterprise Library Configurator (Simple: Added new policy for all exception, added handler which passes to Logging Block. Than it is written to Windows Event System)

However, when I'm instantiating my objects using VirtualMethodInterceptor - it doesn't handle any exception. When I switch to TransparentProxyInterceptor - it works.

I use code for creating object like that:

_container.RegisterType<T, TK>(
            new ContainerControlledLifetimeManager(),
            new InterceptionBehavior<PolicyInjectionBehavior>(), 
            new Interceptor<VirtualMethodInterceptor>())

What's the problem? TransparentProxyInterceptor is slow, and it is better not to use it.

I use Unity 5.0

Upd. Forgot to say: I'm using an attribute to indicate methods that should be handled:
[ExceptionCallHandler("Policy")]

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

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

发布评论

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

评论(1

素罗衫 2024-12-12 20:31:30

我想我发现了我的问题 - 错过了 VirtualMethodInterceptor 和 InterfaceInterceptor。

谢谢

I think I found my problem - missed VirtualMethodInterceptor and InterfaceInterceptor.

Thanks

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