I'm writing a Silverlight application that needs to interface with a server via GET/POST requests. My code looks like the following:
Uri serviceUri = new Uri(my_URI);
WebClient client = new WebClient();
client.OpenReadCompleted += new OpenReadCompletedEventHandler(OnRequestComplete);
client.OpenReadAsync(serviceUri);
However, when the callback function is called, I am getting a System.Security.SecurityException. I've read multiple questions on here from people with similar errors, however all of their issues seem to stem from cross domain issues while debugging. When I run my code, it runs with http://localhost:... as the domain, so that shouldn't be the issue I don't think. Here's the full error if that helps at all:
{System.Security.SecurityException: Security error.
at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClassa.<EndGetResponse>b__9(Object sendState)
at System.Net.Browser.AsyncHelper.<>c__DisplayClass4.<BeginOnUI>b__0(Object sendState)}
Thanks for any help. This has been a very frustrating issue.
UPDATE:
I screwed around with it a lot and eventually got everything to work. Not 100% what did it though... I ended up copy/pasting the clientaccesspolicy.xml and crossdomain.xml files everywhere imaginable, created a new Silverlight project and copied everything there, along with a few other things. If anyone else runs into this problem, that's about as much advice as I have to give :/