Castle Dynamic Proxy 2.2 beta in the wild!

Jono just pushed the first beta version of the Castle Dynamic Proxy 2.2 to the SourceForge.

Don’t let the minor version number mislead you – this is a substantial improvement over the version 2.1. The changelog contains over 40 positions. I’m going to go over the most important ones here.

  • Official support for Silverlight 2 or newer.
  • Last version to support .NET 2.0.
  • Substantial performance improvements (which includes more aggressive caching). Just see this:
    If you’re interested the code for this pseudo-benchmark is here.

Notice that this benchmark measures only time it takes to generate certain number of distinct proxy types. It is here to outline strengths of new version, and does not serve as reliable comparison. You’re unlikely to observe similar speedup in your application. However if you’re creating many proxy types you will notice better performance. The more proxies, the greater improvement.

  • Better support for medium trust scenarios (you will need .NET 2.0 SP2 for this).
  • Significantly broadened range of supported scenarios around generics.
  • Added logging so that you can gain insight into what DP is doing (see Jonathon’s post here).
  • Improved exception messages, so that they are more descriptive and point to a solution.
  • Changed how proxy types are named so that it looks better in logs.
  • Improved handling of mixins, so that it’s now legal to mix in type that implements the same interface as target type, or proxied type.
  • Improved handling of interface proxies with target interface.
  • Added ability to change not only invocation target but also the proxy target in interface proxies with target interfaces
  • … and many more… see the Changes.txt for the full list.

There are few breaking changes that while should not affect vast majority of users, can affect some.

  • All (almost) interface members are now implemented explicitly by the proxy type. This may affect you if you’re reflecting over the proxy types. There is an exception to this rule – for class proxies, when class implements interface member virtually, that member will be implemented implicitly on the proxy type.
  • invocation.MethodInvocationTarget now always points to the method that overrides proxied method on a target type. This means that it’s null when target is null (for interface proxies).
  • many internally used types changed, but you shouldn’t be affected.


Last but not least.

This is a beta release. Remember it may contain bugs. However we feel it’s pretty stable at this point. Download it, use it, and if you find any issues, report them so that we can fix them before the final release.

Link is here.


Craig Neuwirt says:

Awesome work Krzysztof!!!

This is awesome news!

I noticed you said "Silverlight 2 or newer", but the build on it’s SL2 only? Any immediate plans for an SL3 build? how about an SL4? SL4 is a stretch I know, but all my projects are on SL3 🙁

Cesar Sanz says:


It is indeed a great performance improvement

Eric says:

Does this include a fix to the naked type constraint problem?

Ie. My current Castle cannot mock the following interface:

public interface IContainer
void RegisterType<TFrom, TTo>() where TTo : TFrom;

Target says:

Awesome work Krzysztof!!!

rakeback says:

Wow thats quite an improvement over 2.1, keep up the great work dude! Also just wondering, does it support silverlight 4 beta?