[Mono-list] FileSystemWatcher
Andy Hume
andyhume32 at yahoo.co.uk
Wed Jan 16 15:24:55 EST 2008
> > I have just discovered that the bug is not where I thought it is
> >
> > this file should work under .NET but not mono. As a rule I always
> > compile under .NET http://www.nabble.com/file/p14815890/Form1.vb
> > Form1.vb
> >
> > the crash will occur on line 33
>
> Thanks for the repro, I've been able to reproduce it and will
> inform you when I've fixed it.
>
And there are various workarounds until then. :-) The simplest is do an
explicit cast whenever you access an element of the collection, i.e.
change line 33 to:
If CType(collection(index), thing).num = num Then '...
That works fine, the compiler can then early-bind to the 'num' field.
(If you set Option Strict On, then the compiler would disallow the
former form, and any other uses of late binding...) Apologies if I'm
teaching my granny to such eggs...
Another option is to change to using a Generic collections (i.e.
System.Collections.Generic.List(Of thing)), it is type-safe and thus the
cast is unnecessary. However the VB Collections class uses 1-based
indices whereas the collections classes from the Framework Class Library
are all 0-indexed, so you'd need to make changes respectively...
Andy
More information about the Mono-list
mailing list