我有一个 LINQ 模型,其中包含一个由存储过程填充的实体。该过程返回的几个字段是可为空的位字段,因此我在模型上将它们创建为可为空的 bool 值。我希望它能正常工作,但是当我运行我的应用程序时,我从 System.Runtime.Serialization
...
The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter urn:Nbs.PrePaidCards.ChargebackService:GetUnlinkedChargebacksAndRepresentmentsResult. The InnerException message was 'ValueType 'System.Boolean' cannot be null.'. Please see InnerException for more details.
现在,如果我尝试用 null
填充常规 bool
字段,我就会理解这一点,但由于该属性是 Nullable
,这让我有点难过!
有没有其他人遇到过这个问题并且知道如何解决?
谢谢
最佳答案
问题是由我的客户端上的过时服务引用引起的,因此虽然该服务有一个可为空的 bool 字段,但客户端上的代理仍然需要一个常规的 bool 字段,因此出现序列化异常。
关于c# - LINQ 模型的问题 - 无法将 NULL 分配给可空 bool 值!,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6677546/