您好我有一個處理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