Monotouch 4.0.6:使用 WCF 服务时出现序列化错误

2024-03-16

我正在运行 Mono 2.10,并且刚刚升级到 Monotouch 4.0.

我的应用程序发生错误:

System.NullReferenceException: Object reference not set to an instance of an object
  at System.ServiceModel.Dispatcher.BaseMessagesFormatter.DeserializeReply (System.ServiceModel.Channels.Message message, System.Object[] parameters) [0x000e3] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/BaseMessagesFormatter.cs:281 
  at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeReply (System.ServiceModel.Channels.Message message, System.Object[] parameters) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/BaseMessagesFormatter.cs:89 
  at System.ServiceModel.MonoInternal.ClientRuntimeChannel.Request (System.ServiceModel.Description.OperationDescription od, System.Object[] parameters) [0x001cb] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:552 
  at System.ServiceModel.MonoInternal.ClientRuntimeChannel.DoProcess (System.Reflection.MethodBase method, System.String operationName, System.Object[] parameters) [0x00038] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:482 
  at System.ServiceModel.MonoInternal.ClientRuntimeChannel.Process (System.Reflection.MethodBase method, System.String operationName, System.Object[] parameters) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:462

这是怎么回事?谢谢。

附:使用之前版本的 MT (3.2.6),代码可以完美运行。

更新1:

我已经重新编译了该应用程序。现在例外情况如下:

System.Net.WebException: There was an error on processing web request: Status code 400(BadRequest): Bad Request
  at System.ServiceModel.Channels.HttpRequestChannel+HttpChannelRequestAsyncResult.WaitEnd () [0x0003b] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpRequestChannel.cs:435 
  at System.ServiceModel.Channels.HttpRequestChannel.EndRequest (IAsyncResult result) [0x00029] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpRequestChannel.cs:289 
  at System.ServiceModel.Channels.HttpRequestChannel.Request (System.ServiceModel.Channels.Message message, TimeSpan timeout) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpRequestChannel.cs:63 
  at System.ServiceModel.MonoInternal.ClientRuntimeChannel.Request (System.ServiceModel.Channels.Message msg, TimeSpan timeout) [0x0000b] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:562 
  at System.ServiceModel.MonoInternal.ClientRuntimeChannel.Request (System.ServiceModel.Description.OperationDescription od, System.Object[] parameters) [0x00066] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:517

更新2:

我正在运行单声道版本 2.10.5 和 MT 4.0.6。我正在使用 WCF 并尝试调用外部 Web 服务。

我使用以下代码片段来调用 WS:

CustomBinding custom = new CustomBinding(new BinaryMessageEncodingBindingElement(),
    new HttpTransportBindingElement()
    {
       MaxReceivedMessageSize = 2147483647,
       MaxBufferSize = 2147483647
    }
);                  

EndpointAddress endpoint = new EndpointAddress(myUrl);
client = new MyServiceClient(custom, endpoint);

这个异常被捕获:

System.Net.WebException: There was an error on processing web request: Status code 400(BadRequest): Bad Request
  at System.ServiceModel.Channels.HttpRequestChannel+HttpChannelRequestAsyncResult.WaitEnd () [0x0003b] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpRequestChannel.cs:435 
  at System.ServiceModel.Channels.HttpRequestChannel.EndRequest (IAsyncResult result) [0x00029] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpRequestChannel.cs:289 
  at System.ServiceModel.Channels.HttpRequestChannel.Request (System.ServiceModel.Channels.Message message, TimeSpan timeout) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpRequestChannel.cs:63 
  at System.ServiceModel.MonoInternal.ClientRuntimeChannel.Request (System.ServiceModel.Channels.Message msg, TimeSpan timeout) [0x0000b] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:562 
  at System.ServiceModel.MonoInternal.ClientRuntimeChannel.Request (System.ServiceModel.Description.OperationDescription od, System.Object[] parameters) [0x00066] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:517 
  at System.ServiceModel.MonoInternal.ClientRuntimeChannel.DoProcess (System.Reflection.MethodBase method, System.String operationName, System.Object[] parameters) [0x00038] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:482 
  at System.ServiceModel.MonoInternal.ClientRuntimeChannel.Process (System.Reflection.MethodBase method, System.String operationName, System.Object[] parameters) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:462

如果我使用 basicHttpBinding 什么也不会发生。该消息似乎在网络中丢失了。

client = new MyServiceClient(new BasicHttpBinding(BasicHttpSecurityMode.None), new EndpointAddress(myUrl + "/basic"));

从 WS 返回的结构包含 MyClass 元素的列表。 MyClass 类已标记为 [DataContract attribute],成员已标记为 [DataMember] 属性。如果服务仅返回字符串、整数或枚举,则结果正常。

注意:使用单声道版本 2.10 和 MT 3.2.6,WS 在两种情况下都可以工作。

有什么建议么?先感谢您。


None

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Monotouch 4.0.6:使用 WCF 服务时出现序列化错误 的相关文章

  • 序列化是通过套接字发送数据的最佳选择吗?

    有人告诉我 序列化不是通过套接字发送数据的最佳方法 但他们说他们在一本书上读过一次 并且不确定更好的方法 因为他们以前没有真正做过网络 那么序列化是最好的方法还是有更好的方法 如果这有很大的不同的话 这也是一个游戏 通过搜索有关通过它发送对
  • 表单序列化javascript(无框架)

    想知道 javascript 中是否有一个没有 jquery 或任何框架的函数可以让我序列化表单并访问序列化版本 2023 年更新 Use FormData https developer mozilla org en US docs We
  • 序列化表达式树

    我正在用 C 做一个分布式系统 并且遇到了障碍 我需要能够使用类型序列化谓词 Predicate
  • 更改 JSON.NET 序列化属性名称的方式

    如何更改 Newtonsoft JSON NET 序列化对象属性名称的方式 有几种方法 You can manually control how it serializes using the JsonTextWriter class ht
  • 单元测试序列化有什么要点吗?

    我有一个类 它序列化一组我想要进行单元测试的对象 使用 XML 序列化 我的问题是 感觉我将测试 XML 序列化的 NET 实现 而不是任何有用的东西 我还有一个先有鸡还是先有蛋的场景 为了测试 Reader 我需要一个由 Writer 生
  • WCF 与 .Net 远程处理

    根据本文 http msdn microsoft com en us library bb310550 aspx 带有命名管道的WCF是IPC的最佳选择 它比 Net Remoting快25 左右 我有以下代码 将 WCF 与命名管道与 N
  • 添加对共享类的多个 WCF 服务的服务引用

    我正在尝试将我的 WCF Web 服务拆分为几个服务 而不是一个巨大的服务 但是 Visual Studio Silverlight 客户端 复制了两个服务共享的公共类 这是一个简单的例子来说明我的问题 在此示例中 有两个服务 两者都返回类
  • 通信对象 System.ServiceModel.Channels.ServiceChannel 不能用于通信

    通信对象System ServiceModel Channels ServiceChannel 无法用于通信 因为它处于故障状态 这个错误到底是什么意思 我该如何解决它 您收到此错误是因为您让服务器端发生 NET 异常 并且您没有捕获并处理
  • 自托管 WCF REST 服务和基本身份验证

    我创建了一个自托管的 WCF REST 服务 带有 WCF REST Starter Kit Preview 2 中的一些额外内容 这一切工作正常 我现在正在尝试向服务添加基本身份验证 但我在 WCF 堆栈中遇到了一些相当大的障碍 这阻止了
  • 使用 Python 将对象列表转为 JSON

    我在转换时遇到问题Object实例到 JSON ob Object list name scaping myObj base url u number page for ob in list name json string json du
  • C# Newtonsoft 反序列化 JSON 数组

    我正在尝试使用 Newtonsoft 反序列化数组 以便我可以在列表框中显示来自基于云的服务器的文件 但无论我尝试什么 我总是会收到此错误 Newtonsoft Json JsonReaderException 解析值时遇到意外字符 路径
  • 使用 json 向 RESTful WCF 发送 Post 请求

    我已经尝试了每种组合来发送请求 以从 jQuery 向 RESTful WCF 发送 POST 请求 有人可以模仿并使其发挥作用吗 代码在这里 http pastebin com Ua97919C http pastebin com Ua9
  • 是否可以在自定义 WCF 服务行为中创建 TransactionScope? (异步、等待、TransactionScopeAsyncFlowOption.Enabled)

    TL DR 解释问题的截屏视频 https youtu be B Q3T5KpiYk https youtu be B Q3T5KpiYk Problem 当交易从客户端流向服务时交易 当前变成null after awaiting服务到服
  • 将 Xml 反序列化为对象时出错 - xmlns='' 不是预期的

    我在尝试反序列化某些 XML 时遇到了真正的麻烦 希望有人可以提供一些帮助 我读过很多类似的帖子 但我无法解决这个问题 我正在尝试反序列化 XML
  • WCF:将随机数添加到 UsernameToken

    我正在尝试连接到用 Java 编写的 Web 服务 但有些东西我无法弄清楚 使用 WCF 和 customBinding 几乎一切似乎都很好 除了 SOAP 消息的一部分 因为它缺少 Nonce 和 Created 部分节点 显然我错过了一
  • 使用 Xamarin Forms 显示图像

    Solved 答案是更新所有 nuget 软件包并针对较新版本的 Android 现在图像按预期加载 我对此并不满意 因为我完全使用了 Xamarin 提供的代码 并且针对较新的版本已弃用了代码所依赖的一些项目 初始版本是 Xamarin
  • 如何在 PHP 中反序列化 Perl Data::Dumper 输出

    我在 Perl 中有一个导出变量的结果 如下字符串 VAR1 guard gt undef work hand gt undef images gt 1 gt mini height gt 150 width gt 150 extensio
  • python 3中pickle和_pickle有什么区别?

    我是 python 新手 想要实现fast对象序列化 我尝试使用json 但是太慢了 也尝试使用marshall模块 但是marshall序列化的对象的大小比pickle大6 7倍 所以我决定在我的项目中使用pickle 我读到了有关 cP
  • 设置UITextField的光标位置

    我查看了单点触控示例并尝试过 var range new NSRange selectionStart 1 NumberTextField SelectedTextRange IndexedRange GetRange range 但这会在
  • 使用 iostream << 序列化用户对象

    我想使用运算符 ofstream out file ios out ios binary int i 0xAA out lt lt i 并输出 0x31 0x37 0x30 即 0xAA gt 170 170 如果我使用 write 函数

随机推荐