Given the following DataContract:
[DataContract]
public class GetGameSessionHistory : ValueBaseCasinoIT
{
[DataMember]
public GameSession[] GameSessions => GameSessionsValue.ToArray<GameSession>();
public IEnumerable<GameSession> GameSessionsValue { get; set; }
}
I still get the error message that GetGameSessionHistory is not serializable due to the IEnumerable interface.
System.NotSupportedException: Cannot serialize member GetGameSessionHistory.GameSessionsValue of type System.Collections.Generic.IEnumerable`1[[GameSession, Common, Version=3.45.0.11, Culture=neutral, PublicKeyToken=null]] because it is an interface.
I also tried the approach of removing the overall [DataContract] attribute and specifically ignore the affected members with [IgnoreDataMember]. But unfortunately that leads to the same outcome.
Update 1
The Lambda Expression in the given code was just a step i planned to do. The problem remains the same when using the following DataContract:
[DataContract]
public class GetGameSessionHistory : ValueBaseCasinoIT
{
[DataMember]
public GameSession[] GameSessions { get; set; }
public IEnumerable<GameSession> GameSessionsValue { get; set; }
}
When removing the IEnumerable the message disappears. So the problem can't come from the GameSession type.
Currently I'm using the XmlSerializer.
The Data is used in the following Service:
IAdapterService:
[ServiceContract, XmlSerializerFormat(Style = OperationFormatStyle.Rpc, Use = OperationFormatUse.Encoded), DispatchByBodyBehavior]
public interface IAdapterService
{
[OperationContract(Name = "GetGameSessionHistoryRequest", Action = ""), DispatchBodyElement("GetGameSessionHistoryRequest", "...")]
GetGameSessionHistory GetGameSessionHistory(AuthenticationToken authenticationToken, string playerId, DateTime fromDate, DateTime toDate);
}
AdapterService:
[SoapDocumentService(SoapBindingUse.Literal, RoutingStyle = SoapServiceRoutingStyle.RequestElement)]
[ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)]
public class AdapterService : IAdapterService
{
public GetGameSessionHistory GetGameSessionHistory(AuthenticationToken authenticationToken, string playerId, DateTime fromDate, DateTime toDate)
{ ... }
}
Web.config:
<basicHttpBinding>
<binding name="SoapBinding">
<security mode="None"/>
<readerQuotas maxDepth="4000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="32768"/>
</binding>
</basicHttpBinding>
<service name="...svc.AdapterService" behaviorConfiguration="svcBehavior" >
<endpoint binding="basicHttpBinding" bindingConfiguration="SoapBinding" contract="...IAdapterService" name="AdapterSoapBinding" behaviorConfiguration="withMessageInspector"/>
</service>
What else could cause this problem?