我是这个主题的新手,所以我会尽量说清楚......
我创建了一个 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 无法实例化类的代理:My.Namespace.DistributorService。找不到无参数构造函数。
谁知道问题可能是什么?谢谢!