GDI+ error in asp.net

  • Thread starter Thread starter Mekkala
  • Start date Start date
M

Mekkala

A quick rundown of the situation:

I'm building an ASP.NET application on a Windows 2003 web server. Part
of the application draws a graph to display on an .aspx page using GDI+.
Now, I've made a number of these graphs so far, and they've all worked
just fine. This time, though... I started to write the code for this
particular graph, and tested it as I wrote it. It worked fine up until
I made one small change... I declared a variable with a Single data type
to set the space between the pie chart and the labels for each pie
section. The next time I ran the graph (without making any changes to
the application other than declaring that variable and setting its
value), I got an error on a line of code that disposes of the Graphics
object I used to draw the graph:

Try
' Statements here to draw the graph with the Graphics object
Finally
' Statements to dispose of various objects
If Not (chartGraphics Is Nothing) Then
chartGraphics.Dispose() ' Error on this line
End If
End Try

The error message was "System.NullReferenceException: This object is in
use elsewhere".

After that, every time any code in the entire application used any GDI+
function, it raised the error "System.NullReferenceException: Object
reference not set to an instance of an object."

After getting this error repeatedly, with nothing I did fixing the
problem (even rolling back the application changes to yesterday's
backup), I restarted the server. After that, the GDI+ code worked fine.

So I set about rewriting the code I'd lost when I rolled back the
application, from a backup I'd made right before the rollback. I made
the changes one at a time and tested it after practically every line of
code. Eventually, I got to the point where I'd redone everything except
the code that declared and set the value of the Single I mentioned
earlier. I tested it, it worked fine. I added in that extra code, and
what had happened earlier happened again, exactly as it had before.

I tried this a couple more times with variations in the code I was
using, getting the same problem every time and having to restart the
server every time. At this point I'm pretty much at a standstill. I
need that variable, but no matter how I declare it and set its value, or
what data type I give it, the same thing happens... and anyway, I don't
understand how the hell that variable has anything to do with it to
begin with... I don't even use it in any procedures that use GDI+, and
simply declaring a variable and setting its value shouldn't cause that
kind of error ANYWAY.

So... anyone have any ideas or suggestions? Has anyone ever seen this
before? Is there a fix from Microsoft, or a Knowledge Base article that
might address this? I've done some pretty thorough searches at
msdn.microsoft.com, and came up with nothing.

Anyway, thanks in advance, and I hope you guys can help, because I'm at
the end of my rope :P
 
On Fri 19 Mar 2004 11:57:40a, Mekkala
<[email protected]> kicked back with a beer, ruminated
at length, fell asleep, woke up, lit up a joint, then fell asleep again
after thoughtfully blurting out:

Further update:

I checked the Output window while debugging the app... and when it attempts
to call any GDI+ function, I get a series of about a hundred messages, all
the same:

"An unhandled exception of type 'System.AppDomainUnloadedException'
occurred in Unknown Module.

Additional information: Attempted to access an unloaded AppDomain."

And then it fails.
 
On Fri 19 Mar 2004 11:57:40a, Mekkala
<[email protected]> kicked back with a beer, ruminated
at length, fell asleep, woke up, lit up a joint, then fell asleep again
after thoughtfully blurting out:

Another update:

I found the problem. It was a stupid, idiotic, retarded little mistake on
my part. I'm quite embarrassed right now :P
 
Back
Top