Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 为wcf中的参数传递null会导致对象引用未设置为对象的实例_C#_Wcf_Nullreferenceexception - Fatal编程技术网

C# 为wcf中的参数传递null会导致对象引用未设置为对象的实例

C# 为wcf中的参数传递null会导致对象引用未设置为对象的实例,c#,wcf,nullreferenceexception,C#,Wcf,Nullreferenceexception,很长一段时间以来,我一直在努力寻找解决办法,但运气不佳 我有一个具有以下接口的netnamedpiped srvice [OperationContract] [ServiceKnownType(typeof(SubTable))] float GetValue(Table table); 当我在客户机中用null调用它时 proxy.GetValue(tbl) 由于wcf无法序列化null表达式,因此我得到null表达式 我希望通过这样做能够传递null: if (tbl!= null)

很长一段时间以来,我一直在努力寻找解决办法,但运气不佳

我有一个具有以下接口的netnamedpiped srvice

[OperationContract]
[ServiceKnownType(typeof(SubTable))]
float GetValue(Table table);
当我在客户机中用null调用它时 proxy.GetValue(tbl)

由于wcf无法序列化null表达式,因此我得到null表达式 我希望通过这样做能够传递null:

if  (tbl!= null)
var result = proxyGetValue(tbl);
else
var result = proxyGetValueWhenNull();

您是否尝试过将表包装为另一个类的属性并设置属性[DataMember(IsRequired=false/true)]


使用空输入,您希望获得什么输出?@shree.pat18服务器中的内部逻辑
[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();