Search code examples
autofaccastle-dynamicproxy

Autofac EnableInterfaceInterceptors Error


We updating to Autofac 2.4.4 after moving up to MVC3 and are receiving an exception when we include EnableInterfaceInterceptors on our registration. The exception does not appear until DependencyResolver.Current.GetService<ISite>() is called.

Exception:

Could not load type 'System.Func`2' from assembly 'App.AutofacContrib.DynamicProxy2, Version=2.4.4.705, Culture=neutral, PublicKeyToken=null'.

Registration:

builder.RegisterType<SendEmailTask>().As<ITask>().InstancePerDependency().EnableInterfaceInterceptors();

Note: In order to deal with conflicts in the different versions of Castle we performed an ILMerge on AutofacContrib.DynamicProxy2.dll and Castle.Core.dll.


Solution

  • Looks like a problem with the IL merge - rather than merging, have you tried assembly binding redirects?