You probably need to clean up your icon.
The example for Icon.FromHandle on MSDN shows you how. Unfortunately it requires PInvoke:
[System.Runtime.InteropServices.DllImport("user32.dll", CharSet=CharSet.Auto)]
extern static bool DestroyIcon(IntPtr handle);
And then inside your method:
IntPtr hicon = tempBitmap.GetHicon();
Icon bitmapIcon = Icon.FromHandle(hicon);
// And then somewhere later...
DestroyIcon(bitMapIcon.Handle);
If you call DestoryIcon
before you use it, it may not work. For my own particular instance of this problem, I ended up keeping a reference to the last icon I created and then called DestroyIcon
on it the next time I generated an icon.