我有一个问题,我有一个WCF服务引用,并希望将其注入到客户端的MVC控制器中。这工作得很好,当我不想指定参数,但因为我已经添加用户名和密码凭据的服务,所以这些都必须这样设置,如:Unity无法找到部分类的构造函数
MyServiceRef.ClientCredentials.UserName.UserName = username;
MyServiceRef.ClientCredentials.UserName.Password = password;
我决定尝试使用统一处理用户名和密码通过创建我的服务引用的部分类与构造函数与2个字符串作为用户名和密码的参数,一个isTest(布尔)。
public partial class ProductMasterServiceClientClient
{
public ProductMasterServiceClientClient(string username, string password, bool test)
{
ClientCredentials.UserName.UserName = username;
ClientCredentials.UserName.Password = password;
}
}
,并建立统一,像这样:
container.RegisterType<IProductMasterServiceClient, ProductMasterServiceClientClient>(new InjectionConstructor(new InjectionProperty("username", "test"),new InjectionProperty("password", "password"), new InjectionProperty("test", true)));
但它不工作!我收到以下错误出于某种原因:(
The type com.luzern.co40.web.pm.wsProductMasterService.ProductMasterServiceClientClient does not have a constructor that takes the parameters (InjectionProperty, InjectionProperty, InjectionProperty).
任何为什么它不是为我工作的任何想法:)