title: System.Security.SecurityException While calling web service in silverlight
body: <p>I have created web service and i am calling from silverlight application.</p>
  
  <p>I am getting Inner Exception like: </p>
  
  <p>{System.Security.SecurityException ---> System.Security.SecurityException: Security error.
     at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
     at System.Net.Browser.BrowserHttpWebRequest.&lt;>c_<em>DisplayClassa.b</em>_9(Object sendState)
     at System.Net.Browser.AsyncHelper.&lt;>c_<em>DisplayClass4.b</em>_0(Object sendState)
     --- End of inner exception stack trace ---
     at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
     at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
     at System.Net.WebClient.GetWebResponse(WebRequest request, IAsyncResult result)
     at System.Net.WebClient.DownloadBitsResponseCallback(IAsyncResult result)}</p>
  
  <p>Stack Trace :</p>
  
  <p>"   at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)\r\n   at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)\r\n   at System.Net.WebClient.GetWebResponse(WebRequest request, IAsyncResult result)\r\n   at System.Net.WebClient.DownloadBitsResponseCallback(IAsyncResult result)"</p>
  
  <p>When I google this error : </p>
  
  <p>I came to know that this is issue of cross domain url so i have to add clientaccesspolicy.xml and crossdomain.xml file under <strong>C:\inetpub\wwwroot</strong>.</p>
  
  <p>still am getting same error:</p>
  
  <p>Let me know how to fix this error.</p>
  
  <p>Below code i have used:</p>
  
  <pre><code>            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)
          {
  
          }
  </code></pre>