When deploying a WCF webservice for a Silverligh application I got the following error:
An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is: System.InvalidOperationException: An exception was thrown in a call to a WSDL export extension: System.ServiceModel.Description.DataContractSerializerOperationBehavior contract: <a href="http://tempuri.org/:IWebService">http://tempuri.org/:IWebService</a> ----> System.Runtime.Serialization.InvalidDataContractException: Type 'Project.service.HU_BACH.ScPlacemark' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute.
As you can see from the error you need to add the [Serializable] attribute to all objects that are used within the webservice. After I did this I got the same error for my Linq to Sql objects generated within my DBML. You can make your Linq to Sql objects serializable by changing the dbml setting Serialization Mode to Unidirectional.
2 Replies to “WCF webservice error with DBML objects”
When a new service reference is added to a Silverlight 3 project, a ServiceReferences.ClientConfig file is automatically created. However, it seems to set the default contract attribute on the endpoint element to the wrong value.
Yes!!!!! very useful and exactly what i needed