在Mono上运行eBay C#SDK的未处理异常 [英] Unhandled Exception running eBay C# SDK on Mono
问题描述
我下载了eBay SDK,供我们正在开发的内部应用程序使用.问题是我们正在Mono上开发.当我在.NET上运行eBay Hello World示例时,它显示以下输出:
I downloaded the eBay SDK for use in an internal application we are developing. The catch is we are developing on Mono. When I run the eBay Hello World sample on .NET, it displays the following output:
+++++++++++++++++++++++++++++++++++++++
+ 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运行它时,我得到以下信息:
When I run it with Mono, I get the following:
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...
我找到了解决方法,并将其发布在下面的答案中.
I found a workaround and will post it in an answer below.
推荐答案
我搜索了Xamarin的Bugzilla,却一无所获,但是我发现了与Novell的旧版Mono Bugzilla相关的错误:
I searched Xamarin's Bugzilla and found nothing, but I found this relevant bug posted in Novell's old 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
装饰.
So I dug through the eBay SDK source and found that this was indeed the issue. eBay.Service.Core.Sdk.eBayAPIInterfaceService2
inherits from eBay.Service.Core.Sdk.eBayAPIInterfaceService
, which is decorated with a System.Web.Services.WebServiceBindingAttribute
.
所以我更改了eBay.Service.Core.Sdk.eBayAPIInterfaceService2
,添加了[System.Web.Services.WebServiceBindingAttribute(Name = "eBayAPISoapBinding", Namespace = "urn:ebay:apis:eBLBaseComponents")]
,这样它现在看起来像以下内容:
So I changed eBay.Service.Core.Sdk.eBayAPIInterfaceService2
, adding [System.Web.Services.WebServiceBindingAttribute(Name = "eBayAPISoapBinding", Namespace = "urn:ebay:apis:eBLBaseComponents")]
so that it now looks like the following:
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中的说明从源头进行构建,问题得以解决.
I followed the instructions in the eBay SDK for building from the sources and the problem was solved.
脚注:顺便说一句,如果这是您第一次使用Mono连接到HTTPS Web服务,则可能会立即遇到另一个异常.那个看起来像这样:
Footnote: Incidentally, if this is your first time using Mono to connect to an HTTPS web service, you will likely immediately run into another exception. That one will look like this:
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:_安全性
For the solution to that, go here: http://www.mono-project.com/FAQ:_Security
这篇关于在Mono上运行eBay C#SDK的未处理异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!