0

我正在使用一个使用 wcf 和清晰架构的应用程序,我正在尝试创建一个服务来写入数据库。这是我的服务:(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.
4

1 回答 1

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"));
        }
于 2012-09-28T17:07:21.220 回答