My C# program threw an exception from the following method:

SizeF size = Graphics.MeasureString( text, font );

Unfortunately, the exception’s message was rather obscure: “Parameter is invalid.” 

After an investigation, I discovered the error occurred because the font had been previously disposed

Unfortunately, the Font class does not have the typical IsDisposed property, so there was no way to directly query the font’s disposed state.  But I searched in my code and found where I was calling the font’s Dispose method, and then incorrectly trying to use the font again in my call to the MeasureString method.

Share and Enjoy:
  • Digg
  • Twitter
  • Facebook
  • Reddit
  • StumbleUpon
  • LinkedIn
  • Google Bookmarks
  • Slashdot