具有Sharp架构的WCF - 无法使用ServiceLocator找到所需的类型依赖项

时间:2012-09-27 16:54:26

标签: wcf nhibernate sharp-architecture

我正在使用一个使用wcf和sharp架构的应用程序,我正在尝试创建一个写入数据库的服务。这是我的服务:(Sicaf.Core.Services.Wcf)

[ServiceContract]
public interface IFacturaWcfService : ICloseableAndAbortable
{           
    [OperationContract]
    string ConsultarValorMatricula(string xmlData);
}
    [ServiceBehavior, AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
    public class FacturaWcfService : IFacturaWcfService
    {
        private readonly IFacturaBusiness facturaBusiness;

        public FacturaWcfService(IFacturaBusiness facturaBusiness)
        {
            this.facturaBusiness = facturaBusiness;
        }

        public string ConsultarValorMatricula()
        {
            return facturaBusiness.GetFactura();
        }

        public void Abort() { }

        public void Close() { }
    }

在ComponentRegistrar.cs中:(Sicaf.Core.Services.WebServices)

private static void AddWcfServicesTo(IWindsorContainer container)
        {
            // Since the TerritoriesService.svc must be associated with a concrete class,
            // we must register the concrete implementation here as the service            
            container.AddComponent("facturaWcfService", typeof(FacturaWcfService));
        }

我创建了一个客户端,但是我得到了这个例外:

The needed dependency of type FacturaWcfService could not be located with the ServiceLocator. You'll need to register it with the Common Service Locator (CSL) via your IoC's CSL adapter.

1 个答案:

答案 0 :(得分:0)

我终于找到了我的错误。

在:

 private static void AddCustomRepositoriesTo(IWindsorContainer container)
        {
            // Register Data Layer Services
            container.Register(
                AllTypes.Pick()
                .FromAssemblyNamed("Sicaf.Core.Services.Data")
                .WithService.FirstNonGenericCoreInterface("Sicaf.Core.Services.Services.Data"));                   
        }

在:

 private static void AddCustomRepositoriesTo(IWindsorContainer container)
        {
            // Register Data Layer Services
            container.Register(
                AllTypes.Pick()
                .FromAssemblyNamed("Sicaf.Core.Services.Data")
                .WithService.FirstNonGenericCoreInterface("Sicaf.Core.Services.Services.Data"));

            container.Register(
                AllTypes.Pick()
                .FromAssemblyNamed("SismatV2.Data")
                .WithService.FirstNonGenericCoreInterface("SismatV2.Services.Data"));
        }