custom FaultException in Wcf give probelm============
in FaultException We are getting "The creator of this fault did not specify a Reason."
my Service :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.Runtime.Serialization;
namespace InterFac
{
[ServiceContract]
//[ServiceBehavior (InstanceContextMode=InstanceContextMode.PerCall,
// ConcurrencyMode = ConcurrencyMode.Multiple)]
public interface ISum
{
[OperationContract]
Int32 sum(Int32 a, Int32 b);
[OperationContract]
string GetSlect();
[OperationContract]
[FaultContract(typeof(CustomException))]
string GetMessage();
}
}
[DataContract]
public class CustomException
{
[DataMember]
public string Problemdesc
{
get;
set;
}
[DataMember]
public string Hlink
{
get;
set;
}
}
===============Definition of GetMessage for Creating the Ex===============
public string GetMessage()
{
try
{
int i, j, k;
j = 1;
k = 0;
i = j / k;
}
catch (Exception exp)
{
CustomException obj = new CustomException();
obj.Problemdesc = exp.Message;
obj.Hlink = "http://www.Microsoft.com";
FaultException<CustomException> o = new FaultException<CustomException>(obj);
throw o;
//throw new FaultException(exp.Message);
}
return "No Error";
}
========Client Code where service is Calling ==============================
SumClient client = new SumClient();
Response.Write(client.sum(5, 3));
try
{
Response.Write( client.GetMessage());
}
catch (FaultException<CustomException> ex)
{
Response.Write(ex.Detail.Problemdesc + "<br/>" + ex.Detail.Hlink);
}