2012-09-27 1 views
0

Je travaille avec une application qui utilise wcf et une architecture pointue, j'essaye de créer un service pour écrire dans la base de données. Voici mon service: (Sicaf.Core.Services.Wcf)WCF avec l'architecture Sharp - La dépendance nécessaire de type n'a pas pu être localisée avec le ServiceLocator

[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() { } 
    } 

Dans les 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)); 
     } 

J'ai créé un client mais je reçois cette 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. 

Répondre

0

J'ai finalement trouvé mon erreur.

Avant:

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

Après:

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