我创建了Web服务,并且正在从Silverlight应用程序调用。System.Security.SecurityException在Silverlight中调用Web服务
我得到内部异常,如:
{System.Security.SecurityException ---> System.Security.SecurityException:安全错误。 at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult) at System.Net.Browser.BrowserHttpWebRequest。 <> c_ DisplayClassa.b _9(Object sendState) at System.Net.Browser.AsyncHelper。 <> C_ DisplayClass4.b _0(对象sendState)内部异常堆栈跟踪的 --- ---结束在 System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod,对象状态) 在System.Net。 Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult的asyncResult) 在System.Net.WebClient.GetWebResponse(WebRequest的请求,IAsyncResult的结果) 在System.Net.WebClient.DownloadBitsResponseCallback(IAsyncResult的结果)}
堆栈跟踪:
“在System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod,Objec在System.Net.WebClient上System.Net.WebClient.GetWebResponse(WebRequest请求,IAsyncResult结果)\ r \ n下System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)\ r \ n \ r \ n \ r \ .DownloadBitsResponseCallback(IAsyncResult的结果)”
当我谷歌这样的错误:
我才知道,这是跨域网址,所以我必须在添加C clientaccesspolicy.xml和crossdomain.xml文件的问题: \ inetpub \ wwwroot。
还是我得到同样的错误:
让我知道如何解决这个错误。
下面的代码,我已经使用:
System.Uri uri = new System.Uri("https://[localhost]/CustomerPortalService12/AddAccount/" + "AccountName");
var result = "";
try
{
var webClient = new WebClient();
webClient.DownloadStringCompleted +=webClient_DownloadStringCompleted;
webClient.DownloadStringAsync(uri);
}
catch (Exception ex)
{
var wtf = ex.Message;
}
}
}
void webClient_DownloadStringCompleted(object sender, System.Net.DownloadStringCompletedEventArgs e)
{
}