Friday, April 04, 2008

DataContractSerializer and 0 length array

In short, I don't think the DataContractSerializer for WCF likes 0 length arrays at all. I was getting mysterious exceptions and random crashing of my WCF service. I was using wsHttpBinding and getting some WS-Trust invalid or expired security token message so I switched to basicHttpBinding. When debugging that, after the return of my method on the server side, cassini would crash and I'd get Fatal Execution Engine Error messages in my event log.

I cut my service method down to nearly as simple as it could go:

return new MyClass { Name = "BLARG", Children = new MyClass[0] }

and that was still dying. But when I changed it to
Children = null
everything magically started working.

This really merits more investigation but it's after 5 on a Friday and I'm going home.

No comments: