TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Vinod Kumar
NA
19
22.4k
custom FaultException in Wcf give probelm============
Feb 8 2013 5:17 AM
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);
}
Reply
Answers (
2
)
combo box
calculation in grid view