Ninject.Extensions.Interception 2.0 Released!

by Ian Davis on March 6, 2010

in Announcement

On the heels of the Ninject 2.0 release, I am happy to announce the release of the Ninject Interception Extension 2.0. This release provides API backward compatibility for the 1.5 version as well as new method interception, enhanced binding syntax, automatic property changed notification, as well as support for Castle DynamicProxy 2.2 and LinFu DynamicProxy. I will be writing a follow up post about the new features and usage patterns.

I want to thank Krzysztof Koźmic for his help with the Castle DynamicProxy 2.2 integration and Michael Hart for letting me merge his Ninject 1.5 method interception code into the new extension.

You will find downloads on the GitHub dowload page for .NET 3.5, Silverlight 3, and Mono 2.0. For those using automatic module loading or only want to use one DynamicProxy dependency without worrying about delay loading, there are three .NET 3.5 downloads: Castle+LinFu, Castle, and LinFu. Go get it!

Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DotNetKicks
  • DZone
  • email
  • LinkedIn
  • RSS
  • StumbleUpon
  • Technorati
  • Twitter
  • dminikitin
    Hello,
    Tried Ninject.Extensions.Interception v.2, getting the following exception on the "var obj = kernel.Get<IFoo>();" line.

    This happens only if the module is loaded automatically, i.e. the kernel is initialized with "StandardKernel kernel = new StandardKernel();"

    If the module is loaded explicitly ("StandardKernel kernel = new StandardKernel(new NinjectSettings() { LoadExtensions = false }, new DynamicProxy2Module());") there's no exception and interception works fine.

    Another gotcha (at least looks like one to me) is that the method has to be explicitly declared "virtual" to be interceptable. "public void Foo() {}" will correctly implement its namesake from the interface but interception will not work.

    Other than these things everything works great, it's probably the most useful ninject module. Thank you!

    System.ArgumentException was unhandled
    Message="Target type for the proxy implements IProxyTargetAccessor which is a DynamicProxy infrastructure interface and you should never implement it yourself. Are you trying to proxy an existing proxy?\r\nParameter name: targetType"
    Source="Castle.DynamicProxy2"
    ParamName="targetType"
    StackTrace:
    at Castle.DynamicProxy.Generators.ClassProxyGenerator.EnsureDoesNotImplementIProxyTargetAccessor(Type type, String name)
    at Castle.DynamicProxy.Generators.ClassProxyGenerator..ctor(ModuleScope scope, Type targetType)
    at Castle.DynamicProxy.DefaultProxyBuilder.CreateClassProxyType(Type classToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options)
    at Castle.DynamicProxy.ProxyGenerator.CreateClassProxyType(Type classToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options)
    at Castle.DynamicProxy.ProxyGenerator.CreateClassProxy(Type classToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options, Object[] constructorArguments, IInterceptor[] interceptors)
    at Castle.DynamicProxy.ProxyGenerator.CreateClassProxy(Type classToProxy, ProxyGenerationOptions options, Object[] constructorArguments, IInterceptor[] interceptors)
    at Ninject.Extensions.Interception.ProxyFactory.DynamicProxy2ProxyFactory.Wrap(IContext context, InstanceReference reference)
    at Ninject.Extensions.Interception.Activation.Strategies.ProxyActivationStrategy.Activate(IContext context, InstanceReference reference)
    at Ninject.Activation.Pipeline.<>c__DisplayClass1.<Activate>b__0(IActivationStrategy s)
    at Ninject.Infrastructure.Language.ExtensionsForIEnumerableOfT.Map[T](IEnumerable`1 series, Action`1 action)
    at Ninject.Activation.Pipeline.Activate(IContext context, InstanceReference reference)
    at Ninject.Activation.Context.Resolve()
    at Ninject.KernelBase.<Resolve>b__7(IContext context)
    at System.Linq.Enumerable.<>c__DisplayClass12`3.<CombineSelectors>b__11(TSource x)
    at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
    at System.Linq.Enumerable.<CastIterator>d__aa`1.MoveNext()
    at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)
    at Ninject.ResolutionExtensions.Get[T](IResolutionRoot root, IParameter[] parameters)
    at NinjectTest.Program.Main(String[] args) in C:\dev\NinjectTest\Program.cs:line 136
    at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
    at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
    at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
    at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
    at System.Threading.ThreadHelper.ThreadStart()
    InnerException:
  • innovatian
    Is there any chance you could post a reproduction scenario in the bug tracker (http://github.com/idavis/ninject.extensions.int... I will update the post to mention the virtual method item.

    Thanks!
  • toshihiro
    I'm interested in your product. But I can't find documents and examples.
  • innovatian
    I am working on a follow up post with examples. You can find a lot of examples in the unit tests however.
blog comments powered by Disqus

Previous post:

Next post: