WCF/WF - WCF service exception : InvalidDataContractException

Asked By chendhil on 22-Mar-11 05:39 AM

 this is chendhil. i'm working in silverlight 4, WCF 4.0 with VS 2010 as IDE. I'm working in a customized framework project solution. Our project structure has four solutions , we are separating custom Base Class Libraries in a solution, WCF Services in another, application in 3 rd and Test cases in 4th solution. we are building these solutions in a unique order to run our framework applications by daily. from the past 2 days i'm getting an internal exception error on debugging the code which will be mentioned below:

 System.Runtime.Serialization.InvalidDataContractException: Type 'System.ServiceModel.Security.MessageSecurityException' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute. Alternatively, you can ensure that the type is public and has a parameterless constructor - all public members of the type will then be serialized, and no attributes will be required.

 kindly advice me about the cause of the issue and solution to resolve it.

Sahil Kumar replied to chendhil on 22-Mar-11 08:41 AM


I am trying to analyze this scenario. Please check these following

1)    Your class and all fields should be decorated by [DataContract] and [DataMember]. Which I this its do i think in your   case.

2)    The class should be public and all members should be public

Please share you code so that I can help you out.