-
-
Notifications
You must be signed in to change notification settings - Fork 837
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configured Nested Containers Lose LimitType on Component Registrations - Affects WCF Service Resolution #365
Comments
From perekrestov.stas on May 13, 2012 07:16:46 Here is a solution that shows the mentioned behavior Attachment: AutofacWcfIssue365.zip |
From perekrestov.stas on May 14, 2012 02:44:51 The workaround for this issue: Register WCF services |
From travis.illig on September 21, 2012 09:35:43 Labels: Module-Integration-Wcf |
From travis.illig on December 07, 2012 09:42:12 Some research shows that the difference is that the configured lifetime scope somehow loses the strong type of the registered service. More specifically, when 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. Summary: Configured Nested Containers Lose LimitType on Component Registrations - Affects WCF Service Resolution (was: Registered WCF services loose AspNetCompatibility when AutofacHostFactory.Container=_container.BeginLifetimeScope(b => {}), but not when AutofacHostFactory.Container=_container.BeginLifetimeScope()) |
From travis.illig on December 07, 2012 10:25:01 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. Status: Started |
From travis.illig on December 07, 2012 10:42:45 This issue was closed by revision 83d0dcbd3a31 . Status: Fixed |
From perekrestov.stas on May 13, 2012 23:24:07
What steps will reproduce the problem? 1. Create a simple WCF service
2. Mark it with [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
3. Resolve the service instances using Autofac.Wcf
4. In global.asax put the following
protected void Application_Start(object sender, EventArgs e) {
var builder = new ContainerBuilder();
...
_container = builder.Build();
_containerProvider = new ContainerProvider(_container); //for per-request
//Create a special scope for WCF services
_wcfRootLifetimeScope = _container.BeginLifetimeScope(innerBuilder => {});// the issue is here
AutofacHostFactory.Container = _wcfRootLifetimeScope;
} What is the expected output? What do you see instead? expect: The WCF service should be activated successfully
result:
[InvalidOperationException: The service cannot be activated because it does not support ASP.NET compatibility. ASP.NET compatibility is enabled for this application. Turn off ASP.NET compatibility mode in the web.config or add the AspNetCompatibilityRequirements attribute to the service type with RequirementsMode setting as 'Allowed' or 'Required'.]
System.ServiceModel.Activation.HostedAspNetEnvironment.ValidateCompatibilityRequirements(AspNetCompatibilityRequirementsMode compatibilityMode) +197944
System.ServiceModel.Description.DispatcherBuilder.ValidateDescription(ServiceDescription description, ServiceHostBase serviceHost) +391
System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost) +334
System.ServiceModel.ServiceHostBase.InitializeRuntime() +82
System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) +64
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +789
System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +255
System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +1172
[ServiceActivationException: The service '/autofacService.svc' cannot be activated due to an exception during compilation. The exception message is: The service cannot be activated because it does not support ASP.NET compatibility. ASP.NET compatibility is enabled for this application. Turn off ASP.NET compatibility mode in the web.config or add the AspNetCompatibilityRequirements attribute to the service type with RequirementsMode setting as 'Allowed' or 'Required'..]
System.Runtime.AsyncResult.End(IAsyncResult result) +901424
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +178702
System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar) +136 What version of Autofac are you using? On what version of .NET/Silverlight? Autofac.2.6.1.841, Autofac.Wcf.2.6.1.841, Autofac.Web.2.6.1.841
.net 4.0 Please provide any additional information below. If we modify the mentioned code to:
_container = builder.Build();
_containerProvider = new ContainerProvider(_container); //for per-request
//Create a special scope for WCF services
_wcfRootLifetimeScope = _container.BeginLifetimeScope();
AutofacHostFactory.Container = _wcfRootLifetimeScope;
the problem disappears.
The purpose of the code is to override the default component configuration for my WCF services.
Original issue: http://code.google.com/p/autofac/issues/detail?id=365
The text was updated successfully, but these errors were encountered: