views:

270

answers:

1

I have an object array that I am passing to a WCF call that has DBNull.Value as one of the values. WCF is apparently choking on it because it doesn't know how to serialize it.

Googling it only shows people who replaced the DBNull.Value with something else. Do I have to do that, or is there a way for me to have DBNull.Value on the client be serialized to the same thing on the server?

+1  A: 

See this previous post.

http://stackoverflow.com/questions/948675/why-isnt-my-dbnull-a-singleton-when-i-deserialise-it-using-xmlserialiser.

Also, as an aside, DBNull probably shouldn't be floating around in your service layer, although there is always a reason sometimes :)

MattC
yeah, I'd really rather not have it there. My workaround ended up being translating DBNull into something that WCF likes. Don't laugh!
Lurker Indeed
No laughing here, that's exactly what you should do. Define the contract details and then map either end to conform to those contracts. Ok so DBNull shouldn't be on that side of the service but hey, sometimes you just gotta get it working ;)
MattC