Unity.Wcf
5.9.0
Prefix Reserved
See the version list below for details.
dotnet add package Unity.Wcf --version 5.9.0
NuGet\Install-Package Unity.Wcf -Version 5.9.0
<PackageReference Include="Unity.Wcf" Version="5.9.0" />
paket add Unity.Wcf --version 5.9.0
#r "nuget: Unity.Wcf, 5.9.0"
// Install Unity.Wcf as a Cake Addin
#addin nuget:?package=Unity.Wcf&version=5.9.0
// Install Unity.Wcf as a Cake Tool
#tool nuget:?package=Unity.Wcf&version=5.9.0
Unity.Wcf
Unity.Wcf is a library that allows simple Integration of Microsoft's Unity IoC container with WCF. This project includes a bespoke InstanceProvider that creates a child container per client connection and disposes of all registered IDisposable instances once the connection is terminated.
How to use Unity.Wcf
WAS hosted services
For WAS-based hosting, right click on your svc file in the solution explorer and select View Markup. Next replace CodeBehind="Service1.svc.cs" with Factory="WcfService1.WcfServiceFactory", where WcfService1 is the namespace of your project. If you are using fileless activation and do not have an SVC file, change your web.config instead.
<serviceHostingEnvironment>
<serviceActivations>
<add factory="WcfService1.WcfServiceFactory" relativeAddress="./Service1.svc" service="WcfService1.Service1"/>
</serviceActivations>
<serviceHostingEnvironment>
Open the WcfServiceFactory class that has been added to the root of your application. Add all necessary component registrations. If you are registering IDisposable components that need to be created and destroyed on a per client basis (i.e. an EntityFramework DataContext), please ensure that you use the HierarchicalLifetimeManager:
container
.RegisterType<IService1, Service1>()
.RegisterType<IRespository<Blah>, BlahRepository>()
.RegisterType<IBlahContext, BlahContext>(new HierarchicalLifetimeManager());
Windows Service hosting
If you are hosting your WCF service within a Windows Service using a ServiceHost, replace the ServiceHost instance with the custom Unity.Wcf.UnityServiceHost. You will find that the UnityServiceHost takes in a Unity container as its first parameter but is otherwise identical to the default ServiceHost.
Delete the WcfServiceFactory class that has been added to the root of your application. It is not necessary for non-WAS hosting. Instead, you are free to configure Unity any way you like as long as the configured container is passed into the UnityServiceHost correctly. As with WAS hosting, if you want Unity.WCF to dispose of IDisposable components, you must register those components using the HierarchicalLifetimeManager lifestyle.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net45 is compatible. net451 was computed. net452 was computed. net46 is compatible. net461 was computed. net462 was computed. net463 was computed. net47 is compatible. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
-
.NETFramework 4.5
- System.ServiceModel.Primitives (>= 4.5.3)
- Unity.Container (>= 5.9.0)
-
.NETFramework 4.6
- System.ServiceModel.Primitives (>= 4.5.3)
- Unity.Container (>= 5.9.0)
-
.NETFramework 4.7
- System.ServiceModel.Primitives (>= 4.5.3)
- Unity.Container (>= 5.9.0)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Unity.Wcf:
Package | Downloads |
---|---|
UnityWCF
This package exists for backward compatibility. Otherwise Unity.WCF should be used directly. |
|
PerrequestLifetimeManager
PerrequestLifetimeManager Package description |
|
IXN.Wcf
A personal nuget package for setting up wcf project quickly. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
5.11.1 | 319,732 | 6/20/2019 |
5.10.0 | 46,904 | 3/18/2019 |
5.9.2 | 1,556 | 3/18/2019 |
5.9.1 | 20,581 | 3/2/2019 |
5.9.0 | 27,914 | 1/23/2019 |
4.0.0 | 111,974 | 12/6/2017 |
4.0.0-rc03 | 877 | 11/30/2017 |
4.0.0-rc02 | 7,406 | 10/20/2017 |
3.0.0 | 44,769 | 8/18/2017 |
3.0.0-rc01 | 843 | 8/2/2017 |
2.0.0 | 96,224 | 6/21/2017 |
1.1.0 | 12,517 | 6/21/2017 |
1.0.0 | 266,095 | 1/18/2012 |
This package is compatible with .NET 4.5, 4.6 and 4.7 frameworks.