Getting “Object is read only” error when setting ClientCredentials in WCF

后端 未结 5 916
迷失自我
迷失自我 2021-02-12 16:11

I have a proxy object generated by Visual Studio (client side) named ServerClient. I am attempting to set ClientCredentials.UserName.UserName/Password before opening up a new co

5条回答
  •  独厮守ぢ
    2021-02-12 17:16

    It appears that you can only access these properties pretty early in the instanciation cycle. If I override the constructor in the proxy class (ServerClient), I'm able to set these properties:

    base.ClientCredentials.UserName.UserName = "Sample";
    

    I'm beginning to appreciate the people who suggest not using the automatically built proxies provided by VS.

提交回复
热议问题