我对这个问题的新手,所以我会尽力使这个明确的,因为我可以...Ninject拦截WCF服务
我创建了一个WcfModule,在那里我加载以下包:
Bind<IDistributorService>().To<DistributorService>().InRequestScope().Intercept().With<ExceptionInterceptor>();
起初,我没有收到任何错误,但我把一个InterceptAttribute我的功能:
[AttributeUsage(AttributeTargets.Method)]
public sealed class HandleExceptionsAttribute : InterceptAttribute
{
public override IInterceptor CreateInterceptor(IProxyRequest request)
{
return request.Kernel.Get<ExceptionInterceptor>();
}
}
[HandleExceptions]
public virtual Result<List<DistributorDataContract>> GetDistributor(string id)
{
//...code...
我得到了这个功能的错误:(在法第一行)
private ServiceHost CreateNewServiceHost(Type serviceType, Uri[] baseAddresses, WebHttpBehavior webBehavior, WebHttpBinding webHttpBinding)
{
var host = base.CreateServiceHost(serviceType, baseAddresses);
//...
}
与错误:
InvalidProxyConstructorArgumentsException was unhandled by user code Can not instantiate proxy of class: My.Namespace.DistributorService. Could not find a parameterless constructor.
任何人谁知道这个问题可能是什么?谢谢!