简体   繁体   English

温莎城堡IInterceptor配置(南希错误)

[英]Castle Windsor IInterceptor Configuration (Nancy bug)

So I ran into this issue with the Windsor bootstrapper for Nancy. 因此,我遇到了有关南希(Nancy)的温莎(Windsor)引导程序的问题 I managed to whip together a small test project where I can reproduce what is going wrong. 我设法完成了一个小型测试项目,可以重现出问题所在。 You can find the project here . 您可以在此处找到该项目。

What seems to go wrong is this: DynamicProxy only seems to catch the invocation of the void Handle(Action<string> oncomplete) method and not the string Handle(string input) method that is called on another thread . 似乎出问题的是:DynamicProxy似乎只捕获对void Handle(Action<string> oncomplete)方法的调用,而不是 在另一个线程上 调用的string Handle(string input)方法的调用。 As if the Engine is no longer proxied after it had been sent to another thread. 好像在将 Engine发送到另一个线程之后不再代理该 Engine Scratch that: It's just the call to another method on the same class that is not proxied. 从头开始:只是对未代理的同一类上另一个方法的调用。

This means the output of the program is only 这意味着程序的输出仅

Handled Handle with return type System.Void
test

and not 并不是

Handled Handle with return type System.Void
Handled Handle with return type System.String
test

Is this the expected behaviour of Dynamic Proxy? 这是动态代理的预期行为吗? That proxies on another thread are not longer, well, proxied? 另一个线程上的代理不再被代理吗? Or is there something wrong with the code? 还是代码有问题?

EDIT: Just RTFM'd Dynamic Proxy, and it seems like it Works As Intended . 编辑:只是RTFM的动态代理,似乎它按预期工作 Now how do I configure my IEngine Instance to use the correct kind of Proxy? 现在如何配置IEngine实例以使用正确的代理类型?

Try changing : 尝试更改:

Component.For<MyEngine>().Forward<IEngine>().Interceptors<ScopeInterceptor>());

into

Component.For<MyEngine>().Forward<IEngine>().Forward<MyEngine>().Interceptors<ScopeInterceptor>());

I don't have the time to actually try it but this should force windsor into creating a class proxy, which should solve your issue 我没有时间去实际尝试,但这将迫使Windsor创建一个类代理,这应该可以解决您的问题

Kind regards, Marwijn. 亲切的问候,Marwijn。

-- edit -- -编辑-

for the current link try replacing : 对于当前链接,请尝试替换:

Component.For<IEngine>().ImplementedBy<Engine>()

with: 有:

Component.For<IEngine, Engine>().ImplementedBy<Engine>()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM