JurkMonkey
Programmer
Code:
" at System.Drawing.Font.GetHeight(Graphics graphics)\r\n at System.Drawing.Font.GetHeight()\r\n at System.Drawing.Font.get_Height()\r\n at System.Windows.Forms.Control.get_FontHeight()\r\n at System.Windows.Forms.ComboBox.get_PreferredHeight()\r\n at System.Windows.Forms.ComboBox.get_DefaultSize()\r\n at System.Windows.Forms.Control..ctor()\r\n at System.Windows.Forms.ListControl..ctor()\r\n at System.Windows.Forms.ComboBox..ctor()\r\n at
So I was fighting with this little error for a while. Nobody had a good answer for that. Someone wrote about a font being corrupt after installing office 2007 but that didn't help me either.
What ended up happening is this:
I have a drawing class that manipulates an image using GDI+
In order to draw text I passed in a Font from my main control to draw with. After closing my image I Disposed of that font. Turns out I was disposing the reference to the font that I passed in so now the base control's font was disposed.
When I tried to create a new control on my base control I started getting an error in InitializeComponent() - specifically while trying to create a ComboBox. So now I just orphan the reference to that font ( = null ) rather than dispose of it. The base class will dispose of it correctly when it's ready.
Just thought it's handy for anyone else who runs into this one.