WCF Error - Could not find default endpoint element that references contract 'UserService.UserService'

前端 未结 13 1835
野趣味
野趣味 2020-11-29 02:27

Any ideas how to fix this?

UserService.UserServiceClient userServiceClient = new UserServiceClient();
            userServiceClient.GetUsersCompleted += new          


        
13条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-29 03:07

    You can also set these values programatically in the class library, this will avoid unnecessary movement of the config files across the library. The example code for simple BasciHttpBinding is -

    BasicHttpBinding basicHttpbinding = new BasicHttpBinding(BasicHttpSecurityMode.None);
    basicHttpbinding.Name = "BasicHttpBinding_YourName";
    basicHttpbinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
    basicHttpbinding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
    
    EndpointAddress endpointAddress = new EndpointAddress("http:///Service1/Service1.svc");
    Service1Client proxyClient = new Service1Client(basicHttpbinding,endpointAddress);
    

提交回复
热议问题