Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem With LINQ Model - Can't Assign NULL To Nullable Boolean!

I have a LINQ model containing an entity which is populated by a stored procedure. A couple of the fields returned by the procedure are nullable bit fields, so I've created these as nullable booleans on the model. I'd expect this to work fine, but when I run my application I get the following exception from 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.

Now I'd understand this if I was trying to populate a regular bool field with a null, but since the property is Nullable, this has me a bit stumped!

Had anyone else had this problem and know how to fix it?

Thanks

like image 548
TabbyCool Avatar asked Jul 13 '11 10:07

TabbyCool


1 Answers

The problem was caused by an out of date service reference on my client, so whilst the service had a nullable bool field, the proxy on the client was still expecting a regular bool field, hence the serialization exception.

like image 68
TabbyCool Avatar answered Sep 29 '22 23:09

TabbyCool