I have an exception when I want to send a devExpress session in a composite type in WCF. I tried to make it serializable but I still get the error
information: Type
System.Data.SqlClient.SqlConnection
with data contract nameSqlConnection:http://schemas.datacontract.org/2004/07/System.Data.SqlClient
is not expected. Consider using aDataContractResolver
if you are usingDataContractSerializer
or add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to the serializer.
This the DataContract That I used.
[DataContract]
[Serializable]
[ServiceKnownType(typeof(Session))]
[ServiceKnownType(typeof(SqlConnection))]
[ServiceKnownType(typeof(SqlParameter))]
public class CompositeType
{
Session sValue ;
[DataMember]
public Session SessionValue
{ get {return sValue; } set {sValue = value; } }
}
I use also a method that send this class as parameter
void GetDataUsingDataContract(CompositeType composite);