我正在WCF中使用DDD,工作單元和autofac.wcf做一個項目,並給我出現以下錯誤。配置爲WCF的autofac wcf未註冊到Autofac容器
爲WCF配置的服務「WebCode.Service.WCF.TablasMaestrasService,WebCode.Service.WCF」未向Autofac容器註冊。
Bootstrapper.cs
builder.RegisterType<UnitOfWork>().As<IUnitOfWork>();
builder.RegisterType<DatabaseFactory>().As<IDatabaseFactory>();
builder.RegisterType<SystemRuntimeCacheStorage>().As<ICacheStorage>();
builder
.RegisterAssemblyTypes(typeof(PaisRepository).Assembly)
.Where(t => t.Name.EndsWith("Repository"))
.AsImplementedInterfaces();
builder
.RegisterAssemblyTypes(typeof(PaisService).Assembly)
.Where(t => t.Name.EndsWith("Service"))
.AsImplementedInterfaces();
IContainer container = builder.Build();
container.Resolve<IUnitOfWork>();
container.Resolve<IDatabaseFactory>();
container.Resolve<ICacheStorage>();
AutofacHostFactory.Container = container;
TablasMaestrasService.svc
<%@ ServiceHost
Language="C#"
Debug="true"
Service="WebCode.Service.WCF.TablasMaestrasService,WebCode.Service.WCF"
Factory="Autofac.Integration.Wcf.AutofacServiceHostFactory, Autofac.Integration.Wcf"
CodeBehind="TablasMaestrasService.cs" %>
TablasMaestrasService.cs
[ServiceContract]
public class TablasMaestrasService : ITablasMaestrasService
{
private readonly IPaisService _paisService;
public TablasMaestrasService(IPaisService paisService)
{
_paisService = paisService;
}
public List<PaisDto> GetPaises()
{
return = _paisService.GetAll();
}
}
ITablasMaestrasService.cs
[ServiceContract]
public interface ITablasMaestrasService
{
[OperationContract]
List<PaisDto> GetPaises();
}
可能會發生? 一些幫助
它不是在庫稱爲和驗證進行 – ascariz
我也覺得'[的ServiceContract]'屬性需要上界面,而不是執行。 –