[Mono-bugs] [Bug 577818] New: WebClient.UploadStringAsync always throws NotImplementedException

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sun Feb 7 22:07:33 EST 2010


http://bugzilla.novell.com/show_bug.cgi?id=577818

http://bugzilla.novell.com/show_bug.cgi?id=577818#c0


           Summary: WebClient.UploadStringAsync always throws
                    NotImplementedException
    Classification: Mono
           Product: Mono: Class Libraries
           Version: SVN
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: System
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: aenomoto at novell.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


This is a translation of reported bug from
http://irc.gimite.net/channel/mono-jp/archive/20100206
http://smdn.invisiblefulmoon.net/misc/forum/programming/#n13

(The summary explains it.)

// ---- repro ----
using System;
using System.Net;

class MainClass {
  public static void Main(string[] args)
  {
    using (var client = new WebClient()) {
      client.UploadStringCompleted += delegate(object sender,
UploadStringCompletedEventArgs e) {
        if (e.Error != null)
          Console.WriteLine(e.Error);
      };

      client.UploadStringAsync(new Uri("http://localhost/"), "hoge");

      System.Threading.Thread.Sleep(500);
    }
  }
}

Actual result:
System.Net.WebException: An error occurred performing a WebClient request. --->
System.NotSupportedException: WebClient does not support conccurent I/O
operations.
  at System.Net.WebClient.CheckBusy () [0x00016] in
/srv/files/build/mono/trunk/mcs/class/System/System.Net/WebClient.cs:226 
  at System.Net.WebClient.SetBusy () [0x00008] in
/srv/files/build/mono/trunk/mcs/class/System/System.Net/WebClient.cs:231 
  at System.Net.WebClient.UploadData (System.Uri address, System.String method,
System.Byte[] data) [0x00028] in
/srv/files/build/mono/trunk/mcs/class/System/System.Net/WebClient.cs:520 
  --- End of inner exception stack trace ---
  at System.Net.WebClient.UploadData (System.Uri address, System.String method,
System.Byte[] data) [0x00053] in
/srv/files/build/mono/trunk/mcs/class/System/System.Net/WebClient.cs:528 
  at System.Net.WebClient.UploadString (System.Uri address, System.String
method, System.String data) [0x00028] in
/srv/files/build/mono/trunk/mcs/class/System/System.Net/WebClient.cs:840 
  at System.Net.WebClient.<UploadStringAsync>m__13 (System.Object state)
[0x00007] in
/srv/files/build/mono/trunk/mcs/class/System/System.Net/WebClient.cs:1412 

Proposed fix:

WebClient.UploadStringAsync() calls SetBusy(), and UploadData(), which is
called by UploadStringAsync() calls SetBusy() again. That's the cause of the
issue. Call CheckBusy() instead.

Index: System/System.Net/WebClient.cs
===================================================================
--- System/System.Net/WebClient.cs    (revision 150935)
+++ System/System.Net/WebClient.cs    (working copy)
@@ -1402,7 +1402,7 @@
                 throw new ArgumentNullException ("data");

             lock (this) {
-                SetBusy ();
+                CheckBusy ();
                 async = true;

                 async_thread = new Thread (delegate (object state) {

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list