Closed GoogleCodeExporter closed 8 years ago
Here is a solution that shows the mentioned behavior
Original comment by perekrestov.stas
on 13 May 2012 at 2:16
Attachments:
The workaround for this issue:
Register WCF services
_container.BeginLifetimeScope(innerBuilder => {
//put all necessary registrations overrides here and register wcf services
...
innerBuilder.RegisterType<AutofacService>().As<IAutofacService>().UseWcfSafeRele
ase();
})
Original comment by perekrestov.stas
on 14 May 2012 at 9:44
Original comment by travis.illig
on 21 Sep 2012 at 4:35
Some research shows that the difference is that the configured lifetime scope
somehow loses the strong type of the registered service.
More specifically, when
AutofacHostFactory.Container = container
or when
AutofacHostFactory.Container = container.BeginLifetimeScope()
then in the AutofacHostFactory.CreateServiceHost method, the component registry
locates the registration for the WCF "IAutofacService" and finds that the
"limit type" (the type it'll be resolved to) is the concrete "AutofacService"
type.
However, when there's a configuration action, the
AutofacHostFactory.CreateServiceHost method looks at the registration for WCF
"IAutofacService" and thinks the "limit type" is System.Object - no longer the
actual AutofacService type.
The located type is how WCF generates the service description - using the
attributes off the located type to determine compatibility requirements.
This will also affect the way Autofac determines if the service is a singleton
- it uses that type to look for lifetime-related attributes.
I'll have to look into why it's losing the concrete limit type when there's a
configuration action, but that's not specific to WCF - that will have something
to do with the way nested lifetime scopes are created so it'll be a Core change
and probably not a five-minute-fix.
I've updated the issue description/categorization to reflect the actual source
of the problem.
Original comment by travis.illig
on 7 Dec 2012 at 5:42
Actually... it WAS a five-minute-fix. Well, five minutes of coding, more than
that for tracing it down.
I'll commit the fix shortly. It'll be in the 3.0 final release.
Original comment by travis.illig
on 7 Dec 2012 at 6:25
This issue was closed by revision 83d0dcbd3a31.
Original comment by travis.illig
on 7 Dec 2012 at 6:42
Original issue reported on code.google.com by
perekrestov.stas
on 13 May 2012 at 1:24