1

数据集非常简单

DataSet ds = new DataSet ("Test"); 
ds.Tables.Add ("TestTable");
ds.Tables ["TestTable"].Columns.Add ("ID", typeof(int));

方法调用是这样的

wcfClient.GetCommands(Guid.NewGuid(), ds);

服务器永远不会真正接收到请求,因为在数据集的序列化过程中会引发异常。我知道,因为如果我为“ds”发送一个空值,那么我不会得到异常。

我已经尝试过使用 BasicHttpBinding 以及使用 TextMessageEncodingBindingElement 的自定义绑定。两种方法都给出相同的例外。有趣的是,如果我使用二进制序列化,我不会得到异常,但是运行本机 .NET 的服务器端由于某种原因无法反序列化它。

例外是

无法为当前元素使用的前缀“”重新定义命名空间

如果我尝试使用 DataContractSerializer 简单地以单声道序列化数据集,它工作正常。

堆栈跟踪,这可能是最能说明问题的是

  at System.Xml.XmlTextWriter.WriteEndAttribute () [0x0010c] in C:\cygwin\sources\mono\mcs\class\System.XML\System.Xml\XmlTextWriter2.cs:961 
  at System.Xml.DefaultXmlWriter.WriteEndAttribute () [0x00000] in C:\cygwin\sources\mono\mcs\class\System.XML\System.Xml\DefaultXmlWriter.cs:116 
  at System.Xml.XmlSimpleDictionaryWriter.WriteEndAttribute () [0x00000] in C:\cygwin\sources\mono\mcs\class\System.Runtime.Serialization\System.Xml\XmlSimpleDictionaryWriter.cs:97 
  at System.Xml.XmlWriter.WriteAttributeString (System.String prefix, System.String localName, System.String ns, System.String value) [0x00025] in C:\cygwin\sources\mono\mcs\class\System.XML\System.Xml\XmlWriter.cs:270 
  at System.Xml.XmlWriter.WriteAttributeString (System.String localName, System.String value) [0x00000] in C:\cygwin\sources\mono\mcs\class\System.XML\System.Xml\XmlWriter.cs:254 
  at System.Xml.XmlDictionaryWriter.WriteXmlnsAttribute (System.String prefix, System.String namespaceUri) [0x00077] in C:\cygwin\sources\mono\mcs\class\System.Runtime.Serialization\System.Xml\XmlDictionaryWriter.cs:396 
  at System.Runtime.Serialization.DataContractSerializer.WriteStartObject (System.Xml.XmlDictionaryWriter writer, System.Object graph) [0x0022f] in C:\cygwin\sources\mono\mcs\class\System.Runtime.Serialization\System.Runtime.Serialization\DataContractSerializer.cs:499 
  at System.Runtime.Serialization.XmlObjectSerializer.WriteObject (System.Xml.XmlDictionaryWriter writer, System.Object graph) [0x00000] in C:\cygwin\sources\mono\mcs\class\System.Runtime.Serialization\System.Runtime.Serialization\XmlObjectSerializer.cs:113 
  at System.ServiceModel.Dispatcher.DataContractMessagesFormatter+DataContractBodyWriter.WriteMessagePart (System.Xml.XmlDictionaryWriter writer, System.ServiceModel.Description.MessageBodyDescription desc, System.ServiceModel.Description.MessagePartDescription partDesc, System.Object obj) [0x00053] in C:\cygwin\sources\mono\mcs\class\System.ServiceModel\System.ServiceModel.Dispatcher\BaseMessagesFormatter.cs:503 
  at System.ServiceModel.Dispatcher.DataContractMessagesFormatter+DataContractBodyWriter.OnWriteBodyContents (System.Xml.XmlDictionaryWriter writer) [0x00091] in C:\cygwin\sources\mono\mcs\class\System.ServiceModel\System.ServiceModel.Dispatcher\BaseMessagesFormatter.cs:488 
  at System.ServiceModel.Channels.BodyWriter.WriteBodyContents (System.Xml.XmlDictionaryWriter writer) [0x00000] in C:\cygwin\sources\mono\mcs\class\System.ServiceModel\System.ServiceModel.Channels\BodyWriter.cs:57 
  at System.ServiceModel.Channels.SimpleMessage.OnWriteBodyContents (System.Xml.XmlDictionaryWriter writer) [0x00000] in C:\cygwin\sources\mono\mcs\class\System.ServiceModel\System.ServiceModel.Channels\MessageImpl.cs:331 
  at System.ServiceModel.Channels.Message.WriteBodyContents (System.Xml.XmlDictionaryWriter writer) [0x00022] in C:\cygwin\sources\mono\mcs\class\System.ServiceModel\System.ServiceModel.Channels\Message.cs:164 
  at System.ServiceModel.Channels.Message.WriteBody (System.Xml.XmlDictionaryWriter writer) [0x0001c] in C:\cygwin\sources\mono\mcs\class\System.ServiceModel\System.ServiceModel.Channels\Message.cs:149 
  at System.ServiceModel.Channels.Message.OnWriteMessage (System.Xml.XmlDictionaryWriter writer) [0x00065] in C:\cygwin\sources\mono\mcs\class\System.ServiceModel\System.ServiceModel.Channels\Message.cs:274 
  at System.ServiceModel.Channels.Message.WriteMessage (System.Xml.XmlDictionaryWriter writer) [0x00026] in C:\cygwin\sources\mono\mcs\class\System.ServiceModel\System.ServiceModel.Channels\Message.cs:176 
  at System.ServiceModel.Channels.TextMessageEncoder.WriteMessage (System.ServiceModel.Channels.Message message, System.IO.Stream stream) [0x0004a] in C:\cygwin\sources\mono\mcs\class\System.ServiceModel\System.ServiceModel.Channels\TextMessageEncoder.cs:122 
  at System.ServiceModel.Channels.HttpRequestChannel.BeginProcessRequest (System.ServiceModel.Channels.HttpChannelRequestAsyncResult result) [0x003c5] in C:\cygwin\sources\mono\mcs\class\System.ServiceModel\System.ServiceModel.Channels\HttpRequestChannel.cs:166 
  at System.ServiceModel.Channels.HttpRequestChannel.BeginRequest (System.ServiceModel.Channels.Message message, TimeSpan timeout, System.AsyncCallback callback, System.Object state) [0x00012] in C:\cygwin\sources\mono\mcs\class\System.ServiceModel\System.ServiceModel.Channels\HttpRequestChannel.cs:301 
  at System.ServiceModel.Channels.HttpRequestChannel.Request (System.ServiceModel.Channels.Message message, TimeSpan timeout) [0x00000] in C:\cygwin\sources\mono\mcs\class\System.ServiceModel\System.ServiceModel.Channels\HttpRequestChannel.cs:72 
  at System.ServiceModel.MonoInternal.ClientRuntimeChannel.Request (System.ServiceModel.Channels.Message msg, TimeSpan timeout) [0x00013] in C:\cygwin\sources\mono\mcs\class\System.ServiceModel\System.ServiceModel\ClientRuntimeChannel.cs:574 
  at System.ServiceModel.MonoInternal.ClientRuntimeChannel.Request (System.ServiceModel.Description.OperationDescription od, System.Object[] parameters) [0x00066] in C:\cygwin\sources\mono\mcs\class\System.ServiceModel\System.ServiceModel\ClientRuntimeChannel.cs:531 
  at System.ServiceModel.MonoInternal.ClientRuntimeChannel.DoProcess (System.Reflection.MethodBase method, System.String operationName, System.Object[] parameters) [0x00038] in C:\cygwin\sources\mono\mcs\class\System.ServiceModel\System.ServiceModel\ClientRuntimeChannel.cs:496 
  at System.ServiceModel.MonoInternal.ClientRuntimeChannel.Process (System.Reflection.MethodBase method, System.String operationName, System.Object[] parameters) [0x0001c] in C:\cygwin\sources\mono\mcs\class\System.ServiceModel\System.ServiceModel\ClientRuntimeChannel.cs:477 
4

0 回答 0