我想避免这样做:
Using svc As New MyServiceClient svc.ClientCredentials.UserName.UserName = "login" svc.ClientCredentials.UserName.Password = "pw" ... End Using
相反,登录和密码应该是配置的一部分.
svc.ClientCredentials.UserName.UserName = ConfigurationManager.AppSettings("...")
我建议反对这种方法,除非你加密配置文件.