【问题标题】:Unhandled Exception running eBay C# SDK on Mono在 Mono 上运行 eBay C# SDK 的未处理异常
【发布时间】:2013-11-27 15:23:50
【问题描述】:

我下载了 eBay SDK 用于我们正在开发的内部应用程序。问题是我们正在 Mono 上开发。当我在 .NET 上运行 eBay Hello World 示例时,它会显示以下输出:

+++++++++++++++++++++++++++++++++++++++
+ Welcome to eBay SDK for .Net Sample +
+ - HelloWorld                        +
+++++++++++++++++++++++++++++++++++++++
Begin to call eBay API, please wait ...
End to call eBay API, show call result:
eBay official Time: 11/27/2013 3:02:19 PM

当我使用 Mono 运行它时,我得到以下信息:

Unhandled Exception: eBay.Service.Core.Sdk.ApiException: Exception has been thrown by the target of an invocation. 
---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.InvalidOperationException: WebServiceBindingAttribute is required on proxy class 'eBay.Service.Core.Sdk.eBayAPIInterfaceService2'.
at System.Web.Services.Protocols.SoapTypeStubInfo..ctor (System.Web.Services.Protocols.LogicalTypeInfo logicalTypeInfo) [0x00000]
at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (object,object[],System.Exception&)
etc...etc...etc...

我找到了一种解决方法,并将其发布在下面的答案中。

【问题讨论】:

  • 什么版本的单声道?
  • 我使用的是 3.2.3,但根据我在下面的答案中发布的 Novell Bugzilla 报告,这个错误至少从 2.10.x 开始就存在。
  • 这个错误很可能从 0.1 版本开始就存在 ;) 请总是询问有关单声道的问题,请指定您正在使用的版本
  • 道歉......本来是想但忘记了在我的兴奋中发布答案。 :) 谢谢提醒!
  • 嘿,我在使用 mono 时遇到了类似的错误,有没有办法通过在 .config 文件中放入一些东西来绕过它而无需重新编译?

标签: c# mono ebay-sdk


【解决方案1】:

我搜索了 Xamarin 的 Bugzilla,但一无所获,但我在 Novell 的旧 Mono Bugzilla 中发现了这个相关的错误:https://bugzilla.novell.com/show_bug.cgi?id=693367

所以我挖掘了 eBay SDK 源代码,发现这确实是问题所在。 eBay.Service.Core.Sdk.eBayAPIInterfaceService2 继承自 eBay.Service.Core.Sdk.eBayAPIInterfaceService,用 System.Web.Services.WebServiceBindingAttribute 装饰。

所以我更改了eBay.Service.Core.Sdk.eBayAPIInterfaceService2,添加了[System.Web.Services.WebServiceBindingAttribute(Name = "eBayAPISoapBinding", Namespace = "urn:ebay:apis:eBLBaseComponents")],现在它看起来像下面这样:

using System;
using System.Net;
using eBay.Service.Core.Soap;

namespace eBay.Service.Core.Sdk {
    /// <summary>
    /// Enhanced eBayAPIInterfaceService with GZIP compression support.
    /// </summary>
    [System.Web.Services.WebServiceBindingAttribute(Name = "eBayAPISoapBinding", Namespace = "urn:ebay:apis:eBLBaseComponents")]
    internal class eBayAPIInterfaceService2 : eBayAPIInterfaceService {
        ...
    }
}

我按照 eBay SDK 中的说明从源代码构建,问题得到解决。


脚注:顺便说一下,如果这是您第一次使用 Mono 连接到 HTTPS Web 服务,您可能会立即遇到另一个异常。那个看起来像这样:

Unhandled Exception: System.Net.WebException: Error getting response stream (Write: The authentication or decryption has failed.): SendFailure ---> System.IO.IOException: The authentication or decryption has failed. ---> Mono.Security.Protocol.Tls.TlsException: Invalid certificate received from server. Error code: 0xffffffff800b010a
at Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.validateCertificates (Mono.Security.X509.X509CertificateCollection certificates) [0x00000] in <filename unknown>:0 
at Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.ProcessAsTls1 () [0x00000] in <filename unknown>:0 
at Mono.Security.Protocol.Tls.Handshake.HandshakeMessage.Process () [0x00000] in <filename unknown>:0 
at (wrapper remoting-invoke-with-check) Mono.Security.Protocol.Tls.Handshake.HandshakeMessage:Process ()
at Mono.Security.Protocol.Tls.ClientRecordProtocol.ProcessHandshakeMessage (Mono.Security.Protocol.Tls.TlsStream handMsg) [0x00000] in <filename unknown>:0 
at Mono.Security.Protocol.Tls.RecordProtocol.InternalReceiveRecordCallback (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 
--- End of inner exception stack trace ---
at Mono.Security.Protocol.Tls.SslStreamBase.AsyncHandshakeCallback (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 
at System.Net.HttpWebRequest.GetResponse () [0x00000] in <filename unknown>:0 

要解决这个问题,请访问:http://www.mono-project.com/FAQ:_Security

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-06-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多