Autofac and MEF integration

A time ago I have presented a way of implementing wpf plugins with use of Managed Extensibility Framework. Today I will show you how to integrate your MEF exports with Autofac dependency container. For that we will need of course MEF which is stored in System.ComponentModel.Composition assembly, Autofac and Autofac.MEF packages. Having that in place we can manage our MEF export…

By Mirek on (tags: Autofac, MEF, Plugins, categories: architecture)

Memory leak by misusing Autofac

Recently I’ve found out that we can easily cause a memory leaks in our .net application by improper usage of the dependency injection container Autofac. The case of this problem concerns only components that implements IDisposable interface, so are meant to handle some unmanaged resources and need to be disposed when no longer needed. Let me show you how to reproduce this probl…

By Mirek on (tags: Autofac, IDisposable, memory leak, categories: code)

Simple WCF. Hosting WCF service by Autofac in ASP.NET MVC 3

One of features of Autofac is that it can be used to host a WCF service. I have tried to host a WCF service within an already existing ASP.NET MVC 3 web application. The problem was that the service needed to use some resources which were managed by Autofac and was also used this MVC application. I spend few hours until I figure out what is going on and how to make it work toge…

By Mirek on (tags: Autofac, IoC, MVC 3, WCF, categories: code)