[Mono-dev] SystemIcons.Exclamation produces an exception.

Sebastien Pouliot sebastien.pouliot at gmail.com
Sun Dec 3 09:53:04 EST 2006


Hello Konstantin,

On Sun, 2006-12-03 at 02:30 -0800, Konstantin Triger wrote:
> Hi,
> 
> You may use those already committed into SVN, see
> System.Drawing/Assembly.

Oh, I never noticed the icons in that directory. Thanks!

> The JAVA profile has support for system icons, so you may also use
> code from SystemIcons.jvm.cs.

Hmmm... I'm not sure about the code. I don't think this is the way it's
implemented by MS(*) as the pattern looks similar to some old code that
caused us problems in the past. 

E.g. If someone, or some existing code, calling Dispose on one of the
icons, then it icon will throw exception when used afterward.

(*) I'll need to write a few tests to be sure. The solution (to be
previous problems) was to return a Clone of the object.

> Regards,
> Konstantin Triger
> 
> -----Original Message-----
> From: mono-devel-list-bounces at lists.ximian.com
> [mailto:mono-devel-list-bounces at lists.ximian.com] On Behalf Of
> Sebastien Pouliot
> Sent: Sunday, December 03, 2006 3:29 AM
> To: caz yokoyama
> Cc: mono-devel-list at lists.ximian.com
> Subject: Re: [Mono-dev] SystemIcons.Exclamation produces an exception.
> 
> Hello again,
> 
> On Sat, 2006-12-02 at 12:24 -0500, Sebastien Pouliot wrote:
> > Hello Caz,
> > 
> > The class is not implemented. The current stub just returns null for
> any
> > icons.
> > 
> > This makes me wonder where does SWF get it's own icons ;-) There's
> > probably some code/art sharing do be done there.
> 
> ah... MWF delegates the icons to the themes (make sense too).
> 
> I added the code to make SystemIcons works in SVN (one less
> MonoTODO :-). Right now they all return the same mono icon (at least
> you
> won't get an exception). I'll look for appropriate icon this week.
> 
> Thanks
> 
> > On Sat, 2006-12-02 at 08:56 -0800, caz yokoyama wrote:
> > > Has anyone ever used SystemIcons.Exclamation? It produces an
> exception
> > > while it works on Windows. Is this a bug or am I missing
> something?
> > > 
> > >  
> > > 
> > > ------------ icon.cs ----------
> > > 
> > > using System;
> > > 
> > > using System.Drawing;
> > > 
> > > using System.Collections;
> > > 
> > > using System.Drawing.Imaging;
> > > 
> > > using System.Security.Cryptography;
> > > 
> > >  
> > > 
> > > class icon
> > > 
> > > {
> > > 
> > >             public static void Main () {
> > > 
> > >                         Icon aaa = new
> Icon(SystemIcons.Exclamation,
> > > 40, 40);
> > > 
> > >                         Console.WriteLine("Hello World");
> > > 
> > >             }
> > > 
> > > }
> > > 
> > >  
> > > 
> > > -------------- log ---------
> > > 
> > > [caz at localhost icon]$ mcs -debug  -r:System.Drawing.dll icon.cs
> > > 
> > > icon.cs(10,8): warning CS0219: The variable `aaa' is assigned but
> its
> > > value is never used
> > > 
> > > Compilation succeeded - 1 warning(s)
> > > 
> > > [caz at localhost icon]$ mono --debug icon.exe
> > > 
> > >  
> > > 
> > > Unhandled Exception: System.NullReferenceException: Object
> reference
> > > not set to an instance of an object
> > > 
> > >   at System.Drawing.Icon..ctor (System.Drawing.Icon original, Size
> > > size) [0x0001f]
> > >
> in /tmp/scratch/BUILD/mono-1.2.1/mcs/class/System.Drawing/System.Drawing/Icon.cs:129
> > > 
> > >   at System.Drawing.Icon..ctor (System.Drawing.Icon original,
> Int32
> > > width, Int32 height) [0x00000]
> > >
> in /tmp/scratch/BUILD/mono-1.2.1/mcs/class/System.Drawing/System.Drawing/Icon.cs:122
> > > 
> > >   at (wrapper remoting-invoke-with-check)
> System.Drawing.Icon:.ctor
> > > (System.Drawing.Icon,int,int)
> > > 
> > >   at icon.Main () [0x00000] in /home/caz/umd/icon/icon.cs:10
> > > 
> > >  
> > > 
> > > - caz at caztech dot com.
> > > 
> > >  
> > > 
> > > 
> > > _______________________________________________
> > > Mono-devel-list mailing list
> > > Mono-devel-list at lists.ximian.com
> > > http://lists.ximian.com/mailman/listinfo/mono-devel-list
-- 
Sebastien Pouliot  <sebastien at ximian.com>
Blog: http://pages.infinit.net/ctech/




More information about the Mono-devel-list mailing list