NANDA KUMAR

NANDA KUMAR

  • NA
  • 22
  • 2.8k

Custom Objects not exposed after adding faultcontract<custom

Feb 9 2015 10:21 AM

Hi,

I want to throw some custom exception from the service. I am facing problem in it...

After generating the service reference, i have found that, no data contract got exposed and more over i am unable to create the object for the service.

Here is the code i did:

 [ServiceContract]     public interface IService1     {         [FaultContract(typeof(MyExcep))]         [OperationContract]         string GetData(int value);

-- AND SOME MORE METHODS WITH CUSTOM OBJECTS ---
 
}

And Exception is: - 

 [Serializable]     public class MyExcep : CommunicationException        {         public MyExcep()         { }          public MyExcep(string msg)             : base(msg)         { }          protected MyExcep(SerializationInfo info, StreamingContext ctxt)             : base(info, ctxt)         {         }     }


And in the client:

Case 1:

I am getting error on creating the service reference and also other complex types are not also exposed on the client.

I am doing by using "Add service reference". i have also replaced the "communicationexception" and tried by inherting from "exception" class. But no use. Same problem comes.


Case 2:

But without inheriting from exception class and if i marked it as datacontract and using the throw new faultcontact<T> then everything works fine.

May i know what i have did wrong and how to get it correct and how to correct the case 1.?.

Thanks in advance..


Answers (1)