WCF with Sharp architecture - The needed dependency of type could not be located with the ServiceLocator

500 views Asked by At

I'm working with an application which uses wcf and sharp architecture, I'm trying to create a service to write to the database. Here is my service: (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() { }
    }

In the 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));
        }

I created a client but I get this exception:

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

There are 1 answers

0
Francisco Q. On

I've finally found my mistake.

Before:

 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"));                   
        }

After:

 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"));
        }