我想通過WCF線發送異常,但無法弄清楚我做錯了什麼。 我正在關注guidance of Oleg Sych和MSDN,但無濟於事。WCF中的內部異常拋出異常
我回來的是The requested service, 'net.tcp://mymachine/myservicepath/MyService.svc' could not be activated. See the server's diagnostic trace logs for more information.
。
[ServiceContract]
public interface ISystemInfoService
{
[OperationContract]
[FaultContract(typeof(MyException))]
void DoThrowException(string message);
}
//[ServiceContract] // <- the culprit
public class SystemInfoService : ISystemInfoService
{
public void DoThrowException(string message)
{
try
{
throw new MyException("MyMessage");
}
catch (MyExceptionexc)
{
throw new FaultException<MyException>(exc);
}
}
}
// The custom Exception resides in an common assembly reachable from both server and client.
[Serializable]
public class MyException: Exception
{
...
}
TIA
那麼,您是否看過服務器的診斷跟蹤日誌以獲取更多信息? – nvoigt
好點子@nvoigt - 我很慚愧地回答我沒有。當我檢查事件查看器 - >自定義視圖 - >管理事件時,我發現'...合同繼承只能在接口類型之間使用。如果一個類用ServiceContractAttribute標記,它必須是具有ServiceContractAttribute的層次結構中的唯一類型......這顯然是罪魁禍首。我更新了原始代碼以顯示此內容。 – LosManos
@nvoigt - 做一個關於如何到達「服務器的診斷跟蹤日誌」的指令,並且我會很樂意給你你賺得的積分。 – LosManos