Hi, I'm trying to load data into my Silverlight app. However, when it launches, I get a TargetInvocationException as soon as I hit e.Result:
public MainPage() {
WebClient wc = new WebClient();
wc.OpenReadCompleted += new OpenReadCompletedEventHandler(wc_OpenReadCompleted);
wc.OpenReadAsync(new Uri("http://www.google.com"));
}
void wc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e) {
Stream st = e.Result;
StreamReader sr = new StreamReader(st);
String result = sr.ReadToEnd();
}
Why does this fail, and what should I do to make it work?
PS, I'm afraid I cannot make a local proxy, because the app is going to be deployed as part of an app on an Apache Tomcat server, not an IIS.
Cheers
Nik