Skip to content

Instantly share code, notes, and snippets.

@nblumhardt
nblumhardt / NoResourceTrackingInAutofac.cs
Created January 7, 2011 23:28
Disable disposable resource tracking for a service in Autofac
var builder = new ContainerBuilder();
// The thing we want to create haphazardly without ever
// disposing it or any of its dependencies:
builder.RegisterType<Foo>()
.Named<IFoo>("untracked");
// Owned<T> is itself untracked (i.e. disposal is up to the
// owner.) Since we just let the Owned<IFoo> slip away, it