Re: Problem with Graphics Class...
From: Sujith Manuel (sujith_at_rarefind.com)
Date: 03/08/04
- Previous message: Harsh: "DATA GRID BIG PROBLEM... Is this bug?"
- In reply to: Bob Powell [MVP]: "Re: Problem with Graphics Class..."
- Next in thread: Bob Powell [MVP]: "Re: Problem with Graphics Class..."
- Reply: Bob Powell [MVP]: "Re: Problem with Graphics Class..."
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 8 Mar 2004 20:11:03 +0530
Hello Bob,
Here's the code that causes exception:
--------------------------------------------
System.Windows.Forms.Form frm = new System.Windows.Forms.Form();
RectangleF rect = new RectangleF(0, 0, width, height);
System.Drawing.Imaging.Metafile metafile =
new System.Drawing.Imaging.Metafile(frm.CreateGraphics().GetHdc(), rect,
System.Drawing.Imaging.MetafileFrameUnit.Pixel);
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(metafile);
g.DrawArc(pen, 0, 0, width, height, startAngle, sweepAngle);
g.Dispose();
frm.Dispose();
-------------------------------------------
If this code block is called mutiple times, then the exception keeps coming
for a number of times.
Thanks in advance,
Sujith Manuel.
"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:OyHMP8OBEHA.2308@tk2msftngp13.phx.gbl...
> Please post the code that causes the exception.
>
> --
> Bob Powell [MVP]
> Visual C#, System.Drawing
>
> Check out February's edition of Well Formed.
> Non-client drawing, Graphics Transform stack and Flood-Filling
> http://www.bobpowell.net/currentissue.htm
>
> Answer those GDI+ questions with the GDI+ FAQ
> http://www.bobpowell.net/gdiplus_faq.htm
>
> Read my Blog at http://bobpowelldotnet.blogspot.com
>
> "Sujith Manuel" <sujith@rarefind.com> wrote in message
> news:Os92B%23MBEHA.1456@TK2MSFTNGP09.phx.gbl...
> > Hi All,
> >
> > I have a problem with System.Drawing.Graphics class. Whenever I use an
> > object of graphics class, after it goes out of scope, it's giving me an
> > exception as follows:
> >
> > "An unhandled exception of type 'System.InvalidOperationException'
> occurred
> > in system.drawing.dll"
> > "Additional information: The object is currently in use elsewhere."
> >
> > Iam also using Dispose() method of Graphics Class. Anybody knows about
> this
> > behavior and because of this it's consuming a lot of memory.
> >
> > Thanks in advance,
> > Sujith Manuel.
> >
> >
>
>
- Previous message: Harsh: "DATA GRID BIG PROBLEM... Is this bug?"
- In reply to: Bob Powell [MVP]: "Re: Problem with Graphics Class..."
- Next in thread: Bob Powell [MVP]: "Re: Problem with Graphics Class..."
- Reply: Bob Powell [MVP]: "Re: Problem with Graphics Class..."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|