在Mono(3.0.10)中通过WCF发送DataSet会导致序列化期间出现XmlException

时间:2013-06-25 15:07:54

标签: wcf serialization mono dataset

数据集非常简单

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

方法调用是这样的

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

服务器实际上从未收到请求,因为在DataSet序列化期间抛出了异常。我知道,因为如果我为“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 

0 个答案:

没有答案