Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
GitHub or Developer Community with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
Created attachment 18354 [details]
System.Net.WebClient.OpenReadAsync/OpenReadTaskAsync do not work for file:// URLs. See the test case attached to this bug report. Compile the test code like this:
mcs -debug webclienttest.cs
and start it like this:
mono --debug webclienttest.exe webclienttest.cs
You'll get the following exception:
System.InvalidCastException: Specified cast is not valid.
at System.Net.WebClient.OpenReadAsyncCallback (System.IAsyncResult result) [0x00000] in /private/tmp/source-mono-4.6.0-c8sr0/bockbuild-mono-4.6.0-branch-c8sr0/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/referencesource/System/net/System/Net/webclient.cs:1803
at System.Net.LazyAsyncResult.Complete (System.IntPtr userToken) [0x00047] in /private/tmp/source-mono-4.6.0-c8sr0/bockbuild-mono-4.6.0-branch-c8sr0/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/referencesource/System/net/System/Net/_LazyAsyncResult.cs:415
The problem is the following line 1803 in the function "OpenReadAsyncCallback" in the file "mono/mcs/class/referencesource/System/net/System/Net/webclient.cs":
var lazyAsyncResult = (WebAsyncResult) result;
When using file URLs, the incoming result is not a System.Net.WebAsyncResult, instead it is a System.Net.LazyAsyncResult, therefore the type cast fails.
Fixed in master