Reputation: 171
I trying to find a solution for this for a long time with no luck.
I have netnamedpiped srvice with the following interface
[OperationContract]
[ServiceKnownType(typeof(SubTable))]
float GetValue(Table table);
when I call it in the client with null proxy.GetValue(tbl);
I get null expcetion since the wcf can not serialise the null I wouldl like to be able to pass null with doing something like this:
if (tbl!= null)
var result = proxyGetValue(tbl);
else
var result = proxyGetValueWhenNull();
Upvotes: 0
Views: 338
Reputation: 582
Have you tried wrapping the table as a property of another class and setting the attribute [DataMember(IsRequired=false/true)]?
[DataContract]
public class TableWrapper{
[DataMember(IsRequired=false)]
public Table Table{get;set;}
}
[OperationContract]
[ServiceKnownType(typeof(SubTable))]
float GetValue(TableWrapper tableWrapper);
if (tableWrapper.Table!= null)
var result = proxyGetValue(tableWrapper.Table);
else
var result = proxyGetValueWhenNull();
Upvotes: 1