我试图让以下代码在 Mono 控制台应用程序中工作,并作为 MonoTouch 应用程序的最终目标。该代码在使用 Windows 控制台应用程序的 VS2008 下运行良好。
当在 Mac 上将其作为 Mono 控制台应用程序运行时,我得到
未处理的异常:System.NotImplementedException:请求的
功能未实现。在
System.ServiceModel.Channels.SecurityBindingElement.CanBuildChannelFactory[IDuplexChannel]
(System.ServiceModel.Channels.BindingContext 上下文)[0x00000] 中
:0
在 MonoTouch 中,我收到此错误:
未处理的异常:System.ServiceModel.FaultException:错误
验证消息的安全性时发生。在
System.ServiceModel.MonoInternal.ClientRuntimeChannel.Request
(System.ServiceModel.Description.OperationDescription od,
System.Object[] 参数)[0x00188] 中
/Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:545
有人可以解释一下出了什么问题吗?为了简单起见,没有涉及 app.config。
using System;
using MonoAPI3.BLAPI3Session;
using Brainloop.ServiceLibrary.DataModel;
using System.ComponentModel;
using System.ServiceModel;
public static void Main()
{
System.Net.ServicePointManager.ServerCertificateValidationCallback += (se, cert, chain, sslerror) => { return true; };
var oClient = new SessionServiceClient( new BasicHttpBinding( BasicHttpSecurityMode.TransportWithMessageCredential )
{
CloseTimeout = new TimeSpan( 0, 0, 10 ),
OpenTimeout = new TimeSpan( 0, 1, 0 ),
ReceiveTimeout = new TimeSpan( 0, 1, 0 ),
SendTimeout = new TimeSpan( 0, 1, 0 ),
AllowCookies = false,
BypassProxyOnLocal = false,
HostNameComparisonMode = HostNameComparisonMode.StrongWildcard,
MaxBufferSize = 65536,
MaxBufferPoolSize = 524288,
MaxReceivedMessageSize = 65536,
MessageEncoding = WSMessageEncoding.Text,
TextEncoding = System.Text.Encoding.UTF8,
TransferMode = TransferMode.Buffered,
UseDefaultWebProxy = true,
ReaderQuotas = new System.Xml.XmlDictionaryReaderQuotas()
{
MaxDepth = 32,
MaxStringContentLength = 8192,
MaxArrayLength = 16384,
MaxBytesPerRead = 4096,
MaxNameTableCharCount = 16384
}
},
new EndpointAddress( "https://service.myserver.com/Service/V3/Session.svc" ) );
oClient.ClientCredentials.UserName.UserName = "[email protected] /cdn-cgi/l/email-protection";
oClient.ClientCredentials.UserName.Password = "pwd";
SessionInfo oInfo = oClient.StartSession();
Console.WriteLine( "SESSION HASH: " + oInfo.SessionHash );
}