Click here to Skip to main content
15,886,019 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
hai friendz,
I wrote many services for single project....i want to put exception handling in this services...i wanna to display User Friendly messages..

now i want to use one of the following Exceptions..

VB
System.ArgumentException
System.InvalidOperationException
System.NotImplementedException
System.NotSupportedException
System.ApplicationException


UserService.cs:
XML
public class UserService:IUserService
   {
       /// <summary>
       /// Method to InsertUser
       /// </summary>
       /// <param name="Insertuserrequest"></param>
       /// <returns>InsertUserResponse</returns>
       public InsertUserResponse Insert(InsertUserRequest Insertuserrequest)
       {
           InsertUserResponse Insertuserresponse = null;
           try
           {
               Insertuserresponse = UserBLL.Insert(Insertuserrequest);
           }
           catch (BaseException ex)
           {
               throw new FaultException(ex.Summary);
           }

           return Insertuserresponse;
       }
}


UserBLL.cs:


XML
public class UserBLL
    {
        public static  InsertUserResponse Insert(InsertUserRequest Insertuserrequest)
        {
            InsertUserResponse Insertuserresponse = new InsertUserResponse();
           
            try
            {
                if (Insertuserrequest.user.Password != null)
                {
                    Insertuserrequest.user.Password = EncryptPassword(Insertuserrequest.user.Password);
                    Insertuserresponse = UserRepository.Insert(Insertuserrequest);
                }
                else
                {
                    Insertuserresponse = UserRepository.Insert(Insertuserrequest);
                }
               
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return Insertuserresponse;
        }      
    }


How can i use one of the above exception for this method..

Please help me

Thanks in advance
Posted

1 solution

You have to use Fault contract for your custom exception in WCF.
Have a look on this link.
 
Share this answer
 
Comments
.net333 27-Aug-12 6:01am    
Thank you...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900