Tag: autofac
All blog posts with the tag "autofac".
Upcoming decorator enhancements in Autofac 4.9
Published:8 min readAutofac 4.9 introduces new overloads of the existing decorator registration methods that allow for implicit ordering and conditional decoration of services using registration order, as well as support for open-generic registrations and relationship types.
Introducing the Autofac integration for Service Fabric
Published:11 min readThe Autofac.ServiceFabric integration provides lifetime scoping support for Service Fabric services. It uses DynamicProxy interception and custom factory registration classes to track the lifetime of the services within a nested Autofac lifetime scope. This allows for disposal tracking and instance sharing for the service.
Autofac 4.0.0 is in the wild
Published:10 min readAutofac 4.0.0 is the latest version of Autofac and supports .NET Standard 1.1 which includes .NET Core, .NET Framework 4.5, Mono/Xamarin Platforms, Universal Windows Platform 10, Windows 8, and Windows Phone 8.1. It also supports Microsoft's DI abstraction which allows Autofac to integrate with other frameworks such as ASP.NET Core. Issues should be raised in the relevant GitHub repository.
Autofac packages for Visual Studio 2015 release
Published:3 min readAutofac packages for Visual Studio 2015 have been released, with versioning and naming changes to better align with DNX. Documentation is available on the Autofac website.
Autofac 4.0 alpha1 for ASP.NET 5.0 beta3
Published:9 min readAutofac 4.0 alpha1 for ASP.NET 5.0 beta3 is now available on NuGet and can be used with Visual Studio 2015 CTP 6. This version supports the Core CLR without introducing breaking changes, and provides a single integration for the entire web stack. It also includes an Autofac module to encapsulate dependencies. Using this release, developers will be able to create a Web API controller and inject the dependencies they need.
OWIN support for the Web API 2 and MVC 5 integrations in Autofac
Published:5 min readAutofac has recently released pre-release packages for OWIN support for Web API and MVC 5 integrations. These packages enable dependency injection for OWIN middleware components, and extend the Autofac lifetime scope from the OWIN pipeline into the MVC and Web API integrations.
Using Autofac with Self Hosted WCF Services in a Windows Service
Published:5 min readThis article offers an approach to wiring up Autofac with WCF Self Hosting in a Windows Service. It describes creating an Autofac module, an IServiceHostInitializer interface and base implementation, and a ServiceBootstrapper to register and open the service hosts.
Fluent interface for Filter Overrides in the Autofac MVC and Web API integrations
Published:4 min readAutofac now supports overriding filters using the fluent registration API for MVC 5 and Web API 2. This feature is available starting at 3.1.0 of the Autofac.WebApi2 and Autofac.Mvc5 packages on NuGet, and allows for you to add global filters but exclude some from specific actions or controllers.
New features in the Autofac 3.1.0 updates
Published:4 min readAutofac 3.1.0 has been released and includes a number of updates, such as separate XML configuration packages, additional lifetime scopes for request based registrations, Web API HttpRequestMessage injection, and more useful assembly descriptions.
Autofac 3.0.2 update pushed to NuGet
Published:2 min readOn April 8th, 2013, we pushed Autofac 3.0.2 and some minor updates to the core Autofac package and a few of the integration packages to NuGet. These updates include a mix of enhancements and bug fixes across different packages such as SignalR Integration 3.0.1, Web API Integration 3.0.1 and Multitenant Support 3.0.2 and Castle DynamicProxy Integration 3.0.2.
Autofac 3.0 Final Release
Published:2 min readAutofac 3.0 is the final release, with the biggest changes being an official SignalR integration and plenty more documentation on the wiki. The NuGet packages and download zips are now available, along with a list of bug fixes, core and extra NuGet packages.
Autofac 3.0 Beta 2 packages available on NuGet
Published:2 min readAutofac 3.0 Beta 2 is now available on NuGet and includes a number of enhancements and bug fixes, such as the addition of AutoActivate() registration extension, better integration with MVC 4 and Web API filters, and various other improvements and updates to dependencies.
Autofac 3.0 Beta packages available on NuGet
Published:9 min readAutofac 3.0 Beta packages are now available on NuGet, and feature a Portable Class Library that supports multiple frameworks such as .NET Framework 4, Silverlight 5, .NET for Windows Store apps, and Windows Phone 8. It includes XML configuration options, metadata support, an improved registration extension, and bug fixes and enhancements.
New features in the Autofac MVC 4 and Web API (Beta) Integrations
Published:10 min readThis post outlines the new features in the latest pre-release NuGet packages for the Autofac integrations with MVC 4 and Web API. These features include registering filters without attributes, registering per-controller type services, and supporting InstancePerApiControllerType lifetimes.
Autofac 2.6.2.859 and ASP.NET MVC 4 RC Integrations Released
Published:6 min readAutofac 2.6.2.859 was released and includes updates to the core library, ASP.NET MVC 4 RC integration, and ASP.NET Web API RC integration. The core library updates include a new module scanning feature and performance improvements. The ASP.NET MVC and Web API integrations are just recompilations but will have additional features included for the official release.
Selectively resolving services at runtime with Autofac
Published:4 min readThis article explains how to selectively resolve a service at runtime with Autofac by making use of the IEnumerable<Lazy<IExport, IExportMetadata>> and Lazy<T, TMetadata> relationship types. It also provides an example of how to refactor the controller constructor to receive the list of exports and how to query the metadata to select the correct export service at runtime.
Autofac ASP.NET MVC 4 (Beta) Integration
Published:2 min readAutofac 2.6.1 has released a MVC 4 Beta integration, available for download via NuGet, with no breaking changes from the MVC 3 version. The minor change made in the internals allows the lifetime scope applied to a registration to be shared between MVC and the Web API. Users should report any bugs on the issue tracker or ask questions on Stack Overflow using the “autofac” tag.
Autofac ASP.NET Web API (Beta) Integration
Published:9 min readAutofac has released a beta version of the ASP.NET Web API integration package for NuGet, which supports both web hosting and self hosting scenarios. The integration allows for services to be registered per API controller invocation. A HTTP module style implementation is not required due to the IHttpControllerFactory interface allowing for an abstraction between the two hosting modes. The implementation details are discussed in the article.
FilterAttribute Property Injection in Autofac MVC 3 Integration
Published:4 min readThe mechanism for performing property injection on FilterAttributes via ExtensibleActionInvoker had to be removed due to a bug. The new approach leverages the improved dependency injection support added to MVC 3 and requires calling the RegisterFilterProvider method before building the container and providing it to the AutofacDependencyResolver. A custom FilterAttributeFilterProvider and extension method was added to make this work.
View Page Injection in Autofac ASP.NET MVC 3 Integration
Published:5 min readASP.NET MVC 3 provides support for dependency injection on view pages via Autofac, a registration source which allows you to create an adapter that will dynamically provide a registration for a service. Your view pages must inherit from a custom base class and you need to add a registration source called ViewRegistrationSource in the application start event. This allows properties on the view page to be injected by the container.
ASP.NET MVC 3 Beta integration for Autofac
Published:5 min readThe Autofac MVC integration has been updated to provide integration with the ASP.NET MVC 3 Beta, making it easier for users by removing the need to add a reference to the Autofac.Integration.Web.dll assembly, implement the IContainerProviderAccessor interface on the HttpApplication, and register the ContainerDisposalModule in the web.config file. The core piece of the integration is the AutofacDependencyResolver which is an implementation of the IDependencyResolver interface that Brad Wilson outlines in his blog post series on ASP.NET MVC 3 Service Location. A HTTP module called RequestLifetimeModule is registered programmatically via the DynamicModuleUtility class to inform Autofac when the HTTP request has ended.
Introducing Action Injection with Autofac ASP.NET MVC Integration
Published:7 min readAutofac ASP.NET MVC Integration has introduced a new approach to dependency injection called Action Injection, which allows dependencies to be injected into action methods instead of the controller's constructor. This makes it easier to provide mock implementations for unit testing and reduces the number of mocks required.
Making Self-Hosting with Autofac WCF Integration easier
Published:2 min readThis article explains how to use the Autofac WCF integration to make self-hosting WCF services easier. It provides code to extend ServiceHost with a new method called AddDependencyInjectionBehavior which takes an IContainer instance as an argument. This makes the code more concise and eliminates the need to write a separate helper method.
Self-Hosting WCF Services with the Autofac WCF Integration
Published:2 min readThis post provides a demonstration of how to use Autofac's WCF Integration to self-host a web service with a dependency that is injected through the WCF extensibility points. An example and instructions on how to create a client proxy are provided.
Autofac 2.0 Podcast
Published:1 min readNicholas Blumhardt talks about Autofac 2 on the Talking Shop Down Under podcast and can also be heard speaking about Autofac on the .NET Rocks! podcast. He discusses IoC containers in general, the service locator pattern, constructor injection, MEF and Autofac, and Autofac 2's new features.
Registering open generic types in Autofac 1.4
Published:5 min readThis post explains how to extend Autofac 1.4 to register open generic types, with support for both interfaces and classes. It provides an example unit test and the code used to implement the extension method.
Registering open generic interface types in Autofac
Published:8 min readThis post covers how to register open generic interface types in Autofac V2, using the new RegisterAssemblyTypes method and an extension method. Nicholas Blumhardt (the creator of Autofac) suggested that this would be easy to implement, and it was done with a few unit tests and implementation code.