I use the following code block with some more code inside the using block:
using (System.Drawing.Bitmap tempImg = (System.Drawing.Bitmap)tempObj.GetDa
In my case it was an ASP.NET application in which I replaced a single DLL, and I had to simply re-start the application pool after deployment. Then it worked fine.