Attention: We are retiring the ASP.NET Community Blogs. Learn more >

NullReferenceException = LoadFromFile( ... ) ;

The other day I was trying to fix a problem on a website.  The problem was that, whenever I tried to load a file from the filesystem, I received a NullReferenceException being thrown from "GdipLoadImageFromFile"!

Anyways, I got straight onto Justin Rogers who showed me a hack for fixing the problem - just throw in a line which creates a dummy Bitmap and then continue on.  Apparently there's a high probability that GDI+ wasn't being loaded correctly with the simple call to LoadFromFile but, initializing a Bitmap forced it to.

Here's a post from Justin which discusses the problem - and the hack workaround.

     http://weblogs.asp.net/justin_rogers/archive/2004/05/13/131664.aspx

No Comments