I am having a heck of a time trying to get this to work.
I want Autofac to manage my WCF services and use extension less services.
Any ideas why this does not work?
namespace SAIF.Services.WCF.Host
{
using System;
using System.ServiceModel.Activation;
using System.Web;
using System.Web.Routing;
using Autofac;
using Autofac.Integration.Wcf;
using SAIF.Core.Domain;
using SAIF.Core.Domain.Model;
using SAIF.Repositories;
using SAIF.Services.WCF.Core;
using SAIF.Services.WCF.Services;
public class Global : HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
// Create Routes
var factory = new AutofacServiceHostFactory();
RouteTable.Routes.Add(new ServiceRoute("FileService", factory, typeof(SAIF.Services.WCF.Core.IFileService)));
RouteTable.Routes.Add(new ServiceRoute("WebContext", factory, typeof(SAIF.Services.WCF.Core.IWebContextService)));
// Autofac Config
var builder = new ContainerBuilder();
builder.Register(x => new EFUnitOfWork())
.As<EFUnitOfWork>()
.As<IUnitOfWork>();
builder.RegisterGeneric(typeof(Repository<>))
.As(typeof(IRepository<>));
builder.Register(x => new FileService())
.As<IFileService>();
builder.Register(x => new WebContextService(x.Resolve<IRepository<WebContextItem>>(), x.Resolve<IUnitOfWork>()))
.As<IWebContextService>();
AutofacHostFactory.Container = builder.Build();
}
}
}