2
votes

I'm using Autofac with WCF. My service (ExportWebService) needs to take in a dependancy (ExportService). I setup the ApplicationStart to do this:

builder.Register(c => new ExportWebService(c.Resolve<ExportService>()));

But when I do so I get the error:

No scope with a Tag matching 'httpRequest' is visible from the scope in which the instance was requested. This generally indicates that a component registered as per-HTTP request is being reqested by a SingleInstance() component (or a similar scenario.) Under the web integration always request dependencies from the DependencyResolver.Current or ILifetimeScopeProvider.RequestLifetime, never from the container itself.

I've also tried:

builder.RegisterType<ExportWebService>().InstancePerHttpRequest();

In my service I have:

public ExportService ExportService
{
  get;
  set;
}

public ExportWebService(ExportService exportService)
{
  ExportService = exportService;
}

Any idea what is wrong here?

1

1 Answers

1
votes

Autofac WCF support doesn't have InstancePerRequest semantics. There is a detailed FAQ on troubleshooting per-request dependencies that may be interesting, but the short version here would probably be to switch the registration of your ExportService to SingleInstance or InstancePerDependency.