Autofac.Wcf 7.0.0

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
dotnet add package Autofac.Wcf --version 7.0.0
NuGet\Install-Package Autofac.Wcf -Version 7.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Autofac.Wcf" Version="7.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Autofac.Wcf --version 7.0.0
#r "nuget: Autofac.Wcf, 7.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Autofac.Wcf as a Cake Addin
#addin nuget:?package=Autofac.Wcf&version=7.0.0

// Install Autofac.Wcf as a Cake Tool
#tool nuget:?package=Autofac.Wcf&version=7.0.0

Autofac.Wcf

Windows Communication Foundation (WCF) integration for Autofac.

Build status

Please file issues and pull requests for this package in this repository rather than in the Autofac core repo.

Quick Start: Clients

During application startup, for each service register a ChannelFactory<T> and a function that uses the factory to open channels:

var builder = new ContainerBuilder();

// Register the channel factory for the service. Make it
// SingleInstance since you don't need a new one each time.
builder
  .Register(c => new ChannelFactory<ITrackListing>(
    new BasicHttpBinding(),
    new EndpointAddress("http://localhost/TrackListingService")))
  .SingleInstance();

// Register the service interface using a lambda that creates
// a channel from the factory. Include the UseWcfSafeRelease()
// helper to handle proper disposal.
builder
  .Register(c => c.Resolve<ChannelFactory<ITrackListing>>().CreateChannel())
  .As<ITrackListing>()
  .UseWcfSafeRelease();

// You can also register other dependencies.
builder.RegisterType<AlbumPrinter>();

var container = builder.Build();

When consuming the service, add a constructor dependency as normal. This example shows an application that prints a track listing to the console using the remote ITrackListing service. It does this via the AlbumPrinter class:

public class AlbumPrinter
{
  readonly ITrackListing _trackListing;

  public AlbumPrinter(ITrackListing trackListing)
  {
    _trackListing = trackListing;
  }

  public void PrintTracks(string artist, string album)
  {
    foreach (var track in _trackListing.GetTracks(artist, album))
      Console.WriteLine("{0} - {1}", track.Position, track.Title);
  }
}

Quick Start: Services

To get Autofac integrated with WCF on the service side you need to reference the WCF integration NuGet package, register your services, and set the dependency resolver. You also need to update your .svc files to reference the Autofac service host factory.

Here’s a sample application startup block:

protected void Application_Start()
{
  var builder = new ContainerBuilder();

  // Register your service implementations.
  builder.RegisterType<TestService.Service1>();

  // Set the dependency resolver.
  var container = builder.Build();
  AutofacHostFactory.Container = container;
}

And here’s a sample .svc file.

<%@ ServiceHost
    Service="TestService.Service1, TestService"
    Factory="Autofac.Integration.Wcf.AutofacServiceHostFactory, Autofac.Integration.Wcf" %>

Get Help

Need help with Autofac? We have a documentation site as well as API documentation. We're ready to answer your questions on Stack Overflow or check out the discussion forum.

Product Compatible and additional computed target framework versions.
.NET Framework net472 is compatible.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.7.2

NuGet packages (15)

Showing the top 5 NuGet packages that depend on Autofac.Wcf:

Package Downloads
Zen.Core.Host

Модуль Zen.Core предназначенный для автоматического хостинга приложений и вебсервисов в консольном и сервисном режимах

Autofac.Multitenant.Wcf The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

Multitenant applications allow individual tenants to override dependencies rather than having a simple root container for everyone. This extension provides support for an application container and tenant-specific overrides using Autofac when hosting WCF services.

Autofac.Extras.Multitenant.Wcf The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

Multitenant applications allow individual tenants to override dependencies rather than having a simple root container for everyone. This extension provides support for an application container and tenant-specific overrides using Autofac when hosting WCF services.

ImcFramework.Core

core

IME.WCF.SecurityFramework.Authentication

Package Description

GitHub repositories (2)

Showing the top 2 popular GitHub repositories that depend on Autofac.Wcf:

Repository Stars
autofac/Examples
Example projects that consume and demonstrate Autofac IoC functionality and integration
dotnet-architecture/grpc-for-wcf-developers
gRPC for WCF Developers guidance samples
Version Downloads Last updated
7.0.0 8,837 1/27/2024
6.1.0 181,638 7/18/2022
6.0.0 470,249 10/4/2020
5.0.0 393,666 1/30/2020
4.1.0 987,332 5/24/2018
4.0.0 955,283 9/11/2015
3.0.2 112,202 6/17/2015
3.0.1 338,574 3/27/2014
3.0.0 131,689 1/30/2013
3.0.0-beta2 1,675 12/23/2012
3.0.0-beta 1,877 11/1/2012
2.6.3.862 144,790 6/20/2012
2.6.2.859 3,020 6/7/2012
2.6.1.841 10,437 3/5/2012
2.5.2.830 7,565 8/12/2011
2.5.1.827 3,875 7/10/2011
2.4.5.724 6,475 3/12/2011
2.4.4.705 3,457 2/6/2011
2.4.3.700 3,403 1/30/2011
2.4.2.696 4,244 1/24/2011