Re: Graphics.TextRenderingHint throw exception?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



I bet you're caching one you've been given.

The owner will call dispose on it an you'll be left with a disposed reference.

Don't cache Graphics objects.

Mind you, if you just posted all the code instead of feeding us snippets and frustration we'd be able to see and point out the mistakes instead of having to get the ideas through a process of divination...

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





schneider wrote:
I still can't figure this out. Some how I invalidate the Graphics object.

Graphics.Save
Graphics.TextRenderHint
Graphics.MeasureString

all throw ArgumentException "Parameter is not valid.", and I'm not disposing it.

Anyone have any ideas?

Thanks,

Schneider



"schneider" <eschneider@xxxxxxxxxxxxx> wrote in message news:OJ1JATweIHA.3724@xxxxxxxxxxxxxxxxxxxxxxx
Under some cases Graphics.TextRenderingHint and also Graphics.Save throws an exception?

I can't seem to understand why. or what I'm doing wrong? and the error message is useless.

Anyone know whats going on?

Thanks
Schneider



.



Relevant Pages

  • Re: Closing a form
    ... > The articles you mentioned talk about operating on ... > unmanaged code. ... Forms are managed and the articles are dealing with managed code. ... Calling the Dispose() method explicitly is a good ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: SystemPens, SystemBrushes, and FromSystemColor()
    ... Pens or Brushes collections. ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... since you don't call Dispose() on those. ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Unhandled Exception in GDI+
    ... You should have a reference to the image somewhere else other than the pb. ... If so, dispose of that. ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... Dispose code is necessary if you want the object removed from memory ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: Race Condition with GDI+
    ... It seems to me that you are trying to call Dispose() on the Graphics object ... >> Find great Windows Forms articles in Windows Forms Tips and Tricks ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Strange behaviour of shared controls
    ... For further reading check Dispose and Finalize pattern at MSDN. ... Then my controls are gone. ... messages when setting properties of the missing controls though (like ... the same error message as described above. ...
    (microsoft.public.dotnet.general)