Is it possible to intercept a constructor call with dynamic proxy?
I registered a proxy on a class that only contains a constructor as a test but it's not intercepted.
I am guessing that it's currently not possible but maybe there's something special I need to do?
Asked
Active
Viewed 710 times
0

the_drow
- 18,571
- 25
- 126
- 193
1 Answers
1
No it is not possible. For the simple reason that the creation of proxies is managed by ProxyGenerator
which precludes using new
with proxies.

Krzysztof Kozmic
- 27,267
- 12
- 73
- 115
-
Nope. It's one of the fundamental design decisions in Dynamic Proxy - not to alter existing IL and without altering IL you can't intercept constructor calls. You might want to check out LinFu DynamicProxy (version 2or higher) which is fundamentally different from Castle DynamicProxy and I think it does let you do those sorts of things. – Krzysztof Kozmic May 02 '11 at 00:08