Bug 11210 - Possible regression: Delegate example in book throws System.ArgumentExcepion
Summary: Possible regression: Delegate example in book throws System.ArgumentExcepion
Status: RESOLVED NOT_REPRODUCIBLE
Alias: None
Product: Class Libraries
Classification: Mono
Component: System ()
Version: 2.10.x
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-03-17 07:22 UTC by Jan Henrik Hasselberg
Modified: 2014-03-07 04:17 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
WatchDirectory.cs (1.84 KB, text/x-csharp)
2013-03-17 07:22 UTC, Jan Henrik Hasselberg
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and 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 Links.

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.

Related Links:
Status:
RESOLVED NOT_REPRODUCIBLE

Description Jan Henrik Hasselberg 2013-03-17 07:22:12 UTC
Created attachment 3636 [details]
WatchDirectory.cs

Example 2-9 05-delegates/WatchDirectory.cs (page 36)* in "Mono: A Developer's Notebook" (2004) throws "System.ArgumentException: The delegate must have only one target".

How to reproduce:

1) mcs WatchDirectory.cs
2) mono WatchDirectory.exe /tmp
3) Wait until a program writes to /tmp or touch /tmp/foo.txt

Expected output:

Enabled watcher on /tmp; hit return to terminate.
clementine-art-Ud3663.jpg deleted
[...]
clementine-art-Bq3663.jpg changed
foo.txt created
foo.txt changed
clementine-art-wH3663.jpg deleted
[...]

Actual result:

Enabled watcher on /tmp; hit return to terminate.

Unhandled Exception: System.ArgumentException: The delegate must have only one target
  at (wrapper managed-to-native) object:__icall_wrapper_mono_delegate_begin_invoke (object,intptr)
  at (wrapper delegate-begin-invoke) <Module>:begin_invoke_IAsyncResult__this___object_FileSystemEventArgs_AsyncCallback_object (object,System.IO.FileSystemEventArgs,System.AsyncCallback,object)
  at System.IO.FileSystemWatcher.RaiseEvent (System.Delegate ev, System.EventArgs arg, EventType evtype) [0x00000] in <filename unknown>:0 
  at System.IO.FileSystemWatcher.OnDeleted (System.IO.FileSystemEventArgs e) [0x00000] in <filename unknown>:0 
  at System.IO.FileSystemWatcher.DispatchEvents (FileAction act, System.String filename, System.IO.RenamedEventArgs& renamed) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.IO.FileSystemWatcher:DispatchEvents (System.IO.FileAction,string,System.IO.RenamedEventArgs&)
  at System.IO.InotifyWatcher.ProcessEvents (System.Byte[] buffer, Int32 length) [0x00000] in <filename unknown>:0 
  at System.IO.InotifyWatcher.Monitor () [0x00000] in <filename unknown>:0 
  at System.Threading.Thread.StartInternal () [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentException: The delegate must have only one target
  at (wrapper managed-to-native) object:__icall_wrapper_mono_delegate_begin_invoke (object,intptr)
  at (wrapper delegate-begin-invoke) <Module>:begin_invoke_IAsyncResult__this___object_FileSystemEventArgs_AsyncCallback_object (object,System.IO.FileSystemEventArgs,System.AsyncCallback,object)
  at System.IO.FileSystemWatcher.RaiseEvent (System.Delegate ev, System.EventArgs arg, EventType evtype) [0x00000] in <filename unknown>:0 
  at System.IO.FileSystemWatcher.OnDeleted (System.IO.FileSystemEventArgs e) [0x00000] in <filename unknown>:0 
  at System.IO.FileSystemWatcher.DispatchEvents (FileAction act, System.String filename, System.IO.RenamedEventArgs& renamed) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.IO.FileSystemWatcher:DispatchEvents (System.IO.FileAction,string,System.IO.RenamedEventArgs&)
  at System.IO.InotifyWatcher.ProcessEvents (System.Byte[] buffer, Int32 length) [0x00000] in <filename unknown>:0 
  at System.IO.InotifyWatcher.Monitor () [0x00000] in <filename unknown>:0 
  at System.Threading.Thread.StartInternal () [0x00000] in <filename unknown>:0 


* http://books.google.no/books?id=HyszoedfP3MC&pg=PA36&lpg=PA36&dq=05-delegates/WatchDirectory.cs&source=bl&ots=ySvhxnsnj-&sig=u_f4NlmpF1YZCY_sWIJ_waAKcBw&hl=no&sa=X&ei=0qZFUZypF4al4ATGyIGoCg&ved=0CC0Q6AEwAA#v=onepage&q=05-delegates%2FWatchDirectory.cs&f=false
Comment 1 Marek Safar 2014-03-07 04:17:38 UTC
The exception does not occurs in Mono 3.2.8