Can WCF contract methods return null?
I have a fixed size multidimensional set exposed through a WCF contract and I want to be able to return null for any coordinates in a collection that hasn't been populated. When I try to do this, I get an exception indicating that this is not supported: "FaultException`1: An object reference is not set on an object instance."
I wondered if any OperationContract flag could be used, but none is highlighted.
Is this what I want, or is there some internal limitation in WCF?
thank
source to share
As both Garth and Christian have argued, you can indeed return null
from WCF contract methods. In fact, I was caught by my (attempt) cleverness, where the outer (contract) type was converted from the inner type using an implicit conversion operator, within the framework of which the properties of the inner type were available as arguments to the constructor of the outer type. Consequently, NullReferenceException
.
Doh! to me. Quest for G and C. Gart gets to "take" hair, since reading it gave me an instant light bulb.
source to share