簡體   English   中英

未為Autofac容器注冊為WCF配置的autofac wcf

[英]autofac wcf configured for WCF is not registered with the Autofac container

我在WCF中使用DDD,工作單元和autofac.wcf做一個項目,並給我以下錯誤。

為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();
}

那可能正在發生? 一些幫助

注冊您的服務實施:

builder.RegisterType<WebCode.Service.WCF.TablasMaestrasService>();

Autofac文檔

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM