Я хочу получить код исключения из метода wcf, но всегда получаю ошибку NotFound.
Сторона клиента:
public MainPage()
{
InitializeComponent();
client.TestCompleted += new EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(TestCompleted);
}
void TestCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
{
if(e.Error!=null)
{
//HOW to get here my class BaseFault???
}
}
Сторона сервера:
[ServiceContract]
public interface IService1
{
[OperationContract]
[FaultContract(typeof(BaseFault))]
void Test(int id);
}
public void Test(int id)
{
try
{
if (id == -1)
ThrowEx(new BaseFault() { ErrorCode = ProcessErrorsCode.InvalidArgument });
else
throw new NullReferenceException("some server error with null value");
}
catch
{
ThrowEx(new BaseFault() { ErrorCode = ProcessErrorsCode.InternalServerError });
}
}
public void ThrowEx(BaseFault fault)
{
throw new FaultException<BaseFault>(fault);
}
[DataContract]
public class BaseFault
{
[DataMember]
public ProcessErrorsCode ErrorCode { get; set; }
}
Config (includeExceptionDetailInFaults установлено в True):
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="True" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
</configuration>
Мне нужно получить тип BaseFault на стороне клиента.Как это сделать?