我正在尝试在Xamarin iOS项目上使用ServiceStack客户端,在调试时我有以下异常:
"System.ArgumentException:PclExport.Instance需要初始化".
产生异常的代码如下:
try
{
string strReadParam = this.xmlParser.GetString("SyncUrl");
CommonStatic.SyncWSUrl = strReadParam;
var client = new JsonServiceClient(CommonStatic.SyncWSUrl);
client.Timeout = new TimeSpan(0, 0, 0, 5, 0);
var response = client.Get(new mSalesCheckConnectionRequest { DBSource = CommonStatic.DBSource, DBSourceInstance = CommonStatic.DBSourceInstance, DBName = CommonStatic.DBName, DBUsername = CommonStatic.DBUsername, DBPassword = CommonStatic.DBPassword });
return;
}
catch (System.Net.WebException wex)
{
}
Run Code Online (Sandbox Code Playgroud)
我正在使用ServiceStack.Interfaces,ServiceStack.Client.Pcl和ServiceStack.Text.Pcl都具有版本4.0.34.另外,我在6.0.7版本中引用了Newtonsoft.Json.
经过一些研究,我意识到iOS的PCL提供程序没有自动注册,所以我在实例化新的Json服务客户端和我引用的版本4.0.0.0的ServiceStack.Pcl.iOS.dll之前添加了"IosPclExportClient.Configure();" .
结果是以下错误:"不能同时包含'monotouch.dll'和'Xamarin.iOS.dll'在同一个Xamarin.iOS项目中 - 'Xamarin.iOS.dll'被明确引用,而'monotouch.dll'是由'ServiceStack.Pcl.iOS引用,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = null'."
有什么建议可以解决这个问题吗?
先感谢您