Skip to content

Latest commit

 

History

History
27 lines (20 loc) · 2.4 KB

dynamicproxy.md

File metadata and controls

27 lines (20 loc) · 2.4 KB

Castle DynamicProxy

DynamicProxy generates proxies for your objects that you can use to transparently add or alter behavior to them, provide pre/post processing and many other things. Following are just a few better known and popular usages of DynamicProxy:

  • Castle Windsor uses proxies to enable its interception capabilities and for typed factories
  • Moq uses it to provide "the most popular and friendly mocking framework for .NET"
  • NSubstitute uses it to provide "a friendly substitute for .NET mocking frameworks"
  • FakeItEasy uses it to provide "the easy mocking library for .NET"
  • Rhino Mocks uses it to provide "a dynamic mock object framework for the .NET platform"
  • NHibernate uses it to provide lazy loading capabilities (pre-v4.0)

If you're new to DynamicProxy you can read a quick introduction, browse through description of the core types in the library, or go into more advanced, in detail discussion:

ℹ️ Where is Castle.DynamicProxy.dll?: DynamicProxy used to live in its own assembly. As part of changes in version 2.5 it was merged into Castle.Core.dll and that's where you'll find it.

⚠️ Use of a single ProxyGenerator's instance: If you have a long running process (web site, windows service, etc.) and you have to create many dynamic proxies, you should make sure to reuse the same ProxyGenerator instance. If not, be aware that you will then bypass the caching mechanism. Side effects are high CPU usage and constant increase in memory consumption.

See also