1

So I ran into this issue with the Windsor bootstrapper for Nancy. 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. As if the Engine is no longer proxied after it had been sent to another thread. 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. Now how do I configure my IEngine Instance to use the correct kind of Proxy?

Community
  • 1
  • 1
Lodewijk
  • 2,380
  • 4
  • 25
  • 40

1 Answers1

2

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

Kind regards, Marwijn.

-- edit --

for the current link try replacing :

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

with:

Component.For<IEngine, Engine>().ImplementedBy<Engine>()
Community
  • 1
  • 1
Marwijn
  • 1,681
  • 15
  • 24
  • Sorry, the link to my project was not on the correct revision. The revision you looked at actually contained working code, but I don't really want to subclass `Engine` like I did in the revision you looked at. – Lodewijk Jun 13 '13 at 09:41
  • Jep, just edited it. The thing is, if I'm going to subclass Engine, then I don't need DynamicProxy anymore. So I want to avoid that if possible – Lodewijk Jun 13 '13 at 11:02
  • This is what forces Windsor to use the Class Proxy. So, accepted the answer. Sadly a class proxy doesn't solve my underlying problem... – Lodewijk Jun 21 '13 at 09:49