您好我有一个处理wcf异常的问题。 我有这样一个服务:Wcf异常处理抛出错误
[ServiceContract]
public interface IAddressService
{
[OperationContract]
[FaultContract(typeof(ExecuteCommandException))]
int SavePerson(string idApp, int idUser, Person person);
}
我就在WCFTestClient公用事业服务调用SavePerson()。 的SavePerson()的实现是:
public int SavePerson(string idApp, int idUser, Person person)
{
try
{
this._savePersonCommand.Person = person;
this.ExecuteCommand(idUser, idApp, this._savePersonCommand);
return this._savePersonCommand.Person.Id;
}
catch (ExecuteCommandException ex)
{
throw new FaultException<ExecuteCommandException>(ex, new FaultReason("Error in 'SavePerson'"));
}
}
但我得到这个错误:如果我改变SavePerson方法,取而代之的
Failed to invoke the service. Possible causes: The service is offline or inaccessible; the client-side configuration does not match the proxy; the existing proxy is invalid. Refer to the stack trace for more detail. You can try to recover by starting a new proxy, restoring to default configuration, or refreshing the service.
:
catch (ExecuteCommandException ex)
{
throw new FaultException<ExecuteCommandException>(ex, new FaultReason("Error in 'SavePerson'"));
}
我
catch(Exception)
{
throw;
}
我没有得到上述错误,但我只收到异常消息,没有内部异常。 我在做什么错?
是ExecuteCommandException序列化? – 2010-09-06 03:52:19
ExecuteCommandException从Exception继承并标记为可序列化。我发现如果我发送异常发生上述错误。并发现当在服务器端引发异常时,wcf关闭通道并断开客户端。 – Luka 2010-09-06 06:46:01