Silverlight 4应用程序中的RestSharp不';行不通

Silverlight 4应用程序中的RestSharp不';行不通,silverlight,restsharp,clientaccesspolicy.xml,Silverlight,Restsharp,Clientaccesspolicy.xml,我正在Silverlight 4应用程序中使用RestSharp,但它似乎不起作用。。它总是返回System.Security.SecurityException错误 try { client.ExecuteAsync(request, (response) => { if (response.ResponseStatus == ResponseStatus.Error) {

我正在Silverlight 4应用程序中使用RestSharp,但它似乎不起作用。。它总是返回System.Security.SecurityException错误

    try
    {
        client.ExecuteAsync(request, (response) =>
        {
            if (response.ResponseStatus == ResponseStatus.Error)
            {
                Debug.WriteLine(response.ResponseStatus);
            }
            else if (response.ResponseStatus == ResponseStatus.Completed)
            {
               Debug.WriteLine(response.Content);
            }
        });
    }
    catch(System.Security.SecurityException e)
    {
        Debug.WriteLine("Exception : " + e.Message);
    }

Silverlight需要一个
clientaccesspolicy.xml
文件,该文件位于所有要与之通信的服务器的根目录中

如果您只想允许来自任何客户端的通信,可以使用以下示例:

<?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>


由于其他所有非Silverlight客户端都可以访问您的服务,因此我不会再浪费时间配置它,只需使用通用的。

也有同样的问题-添加
clientaccesspolicy.xml
工作

我将该文件添加到VS中的WCF项目中,该项目位于存储
.SVC
文件的同一文件夹中