InvalidOperationException - The type does not have

2019-07-29 00:43发布

问题:

I am having issues resolving WCF using Unity.

Registering WCF channel as below

 string serviceUrl = "http://localhost:8000/AdvancedPersonSelectService.svc";
    IocContainer.Instance.RegisterType<IPersonAdvancedPersonSelectService, AdvancedPersonSelectService>(                      
                   new InjectionFactory(
                   c => WcfClientProxyBuilder.CreateProxy<IPersonAdvancedPersonSelectService>(serviceUrl)));

IocContainer.Instance is the Unity container
wcfClientProxyBuilder returns a WCF channel.

Resolving this by

      var personAdvancedPersonSelectService = IocContainer.Instance.Resolve<IPersonAdvancedPersonSelectService>("AdvancedPersonSelectService");
        var getUserNameresponse = personAdvancedPersonSelectService.GetUserName(request);

At this time i am getting error

Resolution of the dependency failed, type = "Healthphone.ConcordiaCCMS.Common.ServiceContracts.IPersonAdvancedPersonSelectService", name = "AdvancedPersonSelectService". Exception occurred while: while resolving.

Exception is: InvalidOperationException - The type IPersonAdvancedPersonSelectService does not have an accessible constructor.

At the time of the exception, the container was:

Resolving Healthphone.ConcordiaCCMS.Common.ServiceContracts.IPersonAdvancedPersonSelectService,AdvancedPersonSelectService

I have tried all options mentioned in this site as how to do the resolution, but nothing works for me.

can some one please help.

Thanks in advance.