InvalidOperationException - The type does not have an accessible constructor

纵然是瞬间 提交于 2019-12-13 18:13:42

问题


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.

来源:https://stackoverflow.com/questions/19939146/invalidoperationexception-the-type-does-not-have-an-accessible-constructor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!