How to handle Fault in WCF Service Call

Hi
I am calling WCF service but exception is not handled by FaultException and its giving below exception details.
Can anyone please help me on this?

"Error in line 1 position 197. Expecting element 'ExceptionDetail' from namespace 'http://schemas.datacontract.org/2004/07/System.ServiceModel'.. Encountered 'Element' with name 'UnityFault', namespace 'http://schemas.datacontract.org/2004/07/Allscripts.Unity.Services.ObjectDeclarations.Unity'."

 MagicRequest req = new MagicRequest( Parameter1, Parameter2, Parameter3, Parameter4, Parameter5, Parameter6);
            MagicResponse res = new MagicResponse();
            try
            {
                res =
              Task.Factory.FromAsync(
                      (asyncCallback, asyncState) =>
                          _client.BeginMagic(req, asyncCallback, asyncState),
                      (asyncResult) =>
                          _client.EndMagic(asyncResult),null).Result;
            }
            catch (FaultException<UnityFault> ex)
            {                   
                //Exception is not coming here.
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Error :" + ex.ToString());
            }
            return res;

Posts

Sign In or Register to comment.