将 Ninject 集成到 Soap Web 服务中的最佳方式是什么?
我尝试使用 NuGet 和 Ninject.Wcf 包。但是当我尝试使用没有无参数构造函数的 asmx 服务时出现错误。
服务看起来像:
public class Authentication : System.Web.Services.WebService
{
private readonly IDosReactingAuthentication dosReactingAuthentication;
public Authentication(IDosReactingAuthentication dosReactingAuthentication)
{
this.dosReactingAuthentication = dosReactingAuthentication;
}
[WebMethod]
public bool Auth(string domain, string username, string password)
{
return dosReactingAuthentication.Auth(domain, username, password);
}
}
当我消费Auth()
服务时,我总是得到System.MissingMethodException: no parameterless constructor defined for this object.
我也尝试过属性注入,但依赖项始终等于 null。