2012-02-11 2 views
1

Silverlight 4 응용 프로그램에서 RestSharp를 사용하고 있는데 작동하지 않는 것처럼 보입니다. System.Security.SecurityException을 사용하여 항상 ERROR를 반환합니다.Silverlight 4 응용 프로그램의 RestSharp가 작동하지 않습니다.

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); 
    } 

답변

2

실버 라이트는 통신하려는 모든 서버의 루트 디렉토리에 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> 

: 당신은 그냥 모든 클라이언트에서 통신을 허용 할 경우

, 다음과 같은 예를 사용할 수있다 이것은 더 이상 일반적인 것을 사용합니다.

1

동일한 문제가 발생했습니다. clientaccesspolicy.xml 작업을 추가하십시오.

파일을 .SVC 파일이 저장된 동일한 폴더의 VS에서 내 WCF 프로젝트에 추가했습니다.

관련 문제