我正在制作一个Silverlight应用程序,它使用部署在云上的wcf数据服务。 WCF数据服务在浏览器上完美运行,但是当我使用它作为dataservice查询来填充控件并使用loadasync方法时,我得到以下错误。
我包含了clientaccesspolicy.xml和crossdomain.xml,可以访问并向所有域开放。
我使用了fiddler,但它甚至没有尝试检索clientaccesspolicy.xml文件,而是在此之前获取错误。
至少有人知道如何找到错误吗?
e.Error
{System.InvalidOperationException:处理此请求时发生错误。 ---> System.Security.SecurityException ---> System.Security.SecurityException:安全性错误。
在System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
在System.Net.Browser.ClientHttpWebRequest。<> c_ DisplayClass5.b _4(Object sendState)
在System.Net.Browser.AsyncHelper。<> c_ DisplayClass4.b _1(Object sendState)
---内部异常堆栈跟踪结束---
在System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod,Object state)
在System.Net.Browser.ClientHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
在System.Data.Services.Http.ClientHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
在System.Data.Services.Client.QueryResult.AsyncEndGetResponse(IAsyncResult asyncResult)
---内部异常堆栈跟踪结束---
at System.Data.Services.Client.BaseAsyncResult.EndExecute [T](Object source,String method,IAsyncResult asyncResult)
在System.Data.Services.Client.QueryResult.EndExecute [TElement](对象源,IAsyncResult asyncResult)
在System.Data.Services.Client.DataServiceRequest.EndExecute [TElement](对象源,DataServiceContext上下文,IAsyncResult asyncResult)
在System.Data.Services.Client.DataServiceQuery 1.EndExecute(IAsyncResult asyncResult)
at System.Data.Services.Client.DataServiceCollection
1.<> c_ DisplayClass2.b _1(IAsyncResult asyncResult)
在System.Data.Services.Client.DataServiceCollection 1.<>c__DisplayClassd.<>c__DisplayClassf.<BeginLoadAsyncOperation>b__b()}
[System.InvalidOperationException]: {System.InvalidOperationException: An error occurred while processing this request. ---> System.Security.SecurityException ---> System.Security.SecurityException: Security error.
at System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
at System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClass5.<EndGetResponse>b__4(Object sendState)
at System.Net.Browser.AsyncHelper.<>c__DisplayClass4.<BeginOnUI>b__1(Object sendState)
--- End of inner exception stack trace ---
at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
at System.Net.Browser.ClientHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.Data.Services.Http.ClientHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.Data.Services.Client.QueryResult.AsyncEndGetResponse(IAsyncResult asyncResult)
--- End of inner exception stack trace ---
at System.Data.Services.Client.BaseAsyncResult.EndExecute[T](Object source, String method, IAsyncResult asyncResult)
at System.Data.Services.Client.QueryResult.EndExecute[TElement](Object source, IAsyncResult asyncResult)
at System.Data.Services.Client.DataServiceRequest.EndExecute[TElement](Object source, DataServiceContext context, IAsyncResult asyncResult)
at System.Data.Services.Client.DataServiceQuery
1.EndExecute(IAsyncResult asyncResult)
在System.Data.Services.Client.DataServiceCollection 1.<>c__DisplayClass2.<LoadAsync>b__1(IAsyncResult asyncResult)
at System.Data.Services.Client.DataServiceCollection
1.&lt;&gt; c_ DisplayClassd。&lt;&gt; c _DisplayClassf.b_ b()}
数据:{System.Collections.ListDictionaryInternal}
InnerException:{System.Security.SecurityException ---&gt; System.Security.SecurityException:安全性错误。
在System.Net.Browser.ClientHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
在System.Net.Browser.ClientHttpWebRequest。&lt;&gt; c _DisplayClass5.b_ 4(Object sendState)
在System.Net.Browser.AsyncHelper。&lt;&gt; c _DisplayClass4.b_ 1(Object sendState)
---内部异常堆栈跟踪结束---
在System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod,Object state)
在System.Net.Browser.ClientHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
在System.Data.Services.Http.ClientHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
在System.Data.Services.Client.QueryResult.AsyncEndGetResponse(IAsyncResult asyncResult)}
消息:“处理此请求时发生错误。”
StackTrace:“在System.Data.Services.Client.BaseAsyncResult.EndExecute [T](对象源,String方法,IAsyncResult asyncResult)\ r \ n在System.Data.Services.Client.QueryResult.EndExecute [TElement](对象源) ,System.Data.Services.Client.DataServiceQuery {{1在System.Data.Services.Client.DataServiceCollection`1上的&lt;&gt; c _DisplayClass2.b_ 1(IAsyncResult asyncResult)\ r \ n。&lt;&gt; c _DisplayClassd&LT;&GT; C_ DisplayClassf.b _b()“
答案 0 :(得分:0)
<?xml version="1.0" encoding="utf-8"?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="*">
<domain uri="*"/>
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
清除浏览器缓存后,我的clientaccesspolicy已加载,并且工作正常。 希望有所帮助