Edit: I would like to give generosity to this question - time is almost up - all comments below are updated, but there is still no permission.
Getting a weird mistake. I have reduced my code to its absolute simplest form and am still getting an error for the following code.
public partial class MainPage : PhoneApplicationPage { private readonly WebClient webClient; public MainPage() { InitializeComponent(); webClient = new WebClient(); webClient.OpenReadCompleted += clientOpenRead_Completed; } private void LoadButton_Click(object sender, RoutedEventArgs e) { webClient.OpenReadAsync(new Uri(@"validURL")); } private void clientOpenRead_Completed(object sender, System.Net.OpenReadCompletedEventArgs e) { using (var sr = new StreamReader(e.Result)) { Result.Text = sr.ReadToEnd(); } } }
sr.ReadToEnd (); always returns an empty string, and when I check "e.Result" for clientOpenRead_Completed, it contains the following exception:
base {"Timeouts are not supported on this stream."} System.SystemException {System.InvalidOperationException}
Other important checks: validURL runs on browser request. In addition, the above code works fine when called in a console application, and the same URL and similar code work fine in Monodroid.
Finally, the service source is not WCF.
Any ideas?
Thanks.
EDIT: stacktrace at the point where I check e.Result: (from a slightly different project, but with the same problem)
> AppTest.dll!AppTest.Data.AsyncServiceProvider.clientOpenRead_Completed(object sender, System.Net.OpenReadCompletedEventArgs e) Line 20 C# System.Net.dll!System.Net.WebClient.OnOpenReadCompleted(System.Net.OpenReadCompletedEventArgs e) + 0x15 bytes System.Net.dll!System.Net.WebClient.OpenReadOperationCompleted(object arg) + 0xc bytes mscorlib.dll!System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo rtmi, object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, object parameters, System.Globalization.CultureInfo culture, bool isBinderDefault, System.Reflection.Assembly caller, bool verifyAccess, ref System.Threading.StackCrawlMark stackMark) mscorlib.dll!System.Reflection.RuntimeMethodInfo.InternalInvoke(object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, object[] parameters, System.Globalization.CultureInfo culture, ref System.Threading.StackCrawlMark stackMark) + 0x168 bytes mscorlib.dll!System.Reflection.MethodBase.Invoke(object obj, object[] parameters) + 0xa bytes mscorlib.dll!System.Delegate.DynamicInvokeOne(object[] args) + 0x98 bytes mscorlib.dll!System.MulticastDelegate.DynamicInvokeImpl(object[] args) + 0x8 bytes mscorlib.dll!System.Delegate.DynamicInvoke(object[] args) + 0x2 bytes System.Windows.dll!System.Windows.Threading.DispatcherOperation.Invoke() + 0xc bytes System.Windows.dll!System.Windows.Threading.Dispatcher.Dispatch(System.Windows.Threading.DispatcherPriority priority) + 0x83 bytes System.Windows.dll!System.Windows.Threading.Dispatcher.OnInvoke(object context) + 0x8 bytes System.Windows.dll!System.Windows.Hosting.CallbackCookie.Invoke(object[] args) + 0x19 bytes System.Windows.dll!System.Windows.Hosting.DelegateWrapper.InternalInvoke(object[] args) + 0x2 bytes System.Windows.RuntimeHost.dll!System.Windows.RuntimeHost.ManagedHost.InvokeDelegate(System.IntPtr pHandle, int nParamCount, System.Windows.Hosting.NativeMethods.ScriptParam[] pParams, ref System.Windows.Hosting.NativeMethods.ScriptParam pResult) + 0x5e bytes [External Code]