Re: Line OnLostDevice() Exception
- From: Giorgio Tino <giorgio.tino@xxxxxxxxxxxx>
- Date: Tue, 01 May 2007 03:23:31 +0200
Thanks for the answer,
now i'm quite sure the problem is related to the Dispose() pattern i'm implementing... it seems that I was not disposing the Device so it was disposed by the finalizer, in a thread that was different from the one that actualy created it... now it seems that i fixed the problem, but I will have to implement a correct Dispose pattern anyway... Thank you so much for helping!
ZMan ha scritto:
If you are adding your own event handlers you should make sure you turn of the automatic ones.. maybe something is getting confused there.
I think its Device.AutoEventHandler = false; or somethink like that - the property is on the static Device class
"Giorgio Tino" <giorgio.tino@xxxxxxxxxxxx> wrote in message news:%23cszJ3RiHHA.3412@xxxxxxxxxxxxxxxxxxxxxxxHi,
yes I do call the Dispose() myself... This is what I call:
d.DeviceReset += new EventHandler(this.OnDeviceReset);
d.DeviceLost += new EventHandler(this.OnDeviceLost);
d.DeviceDisposing += new EventHandler(this.OnDeviceDisposing);
d.DeviceResizing += new EventHandler(this.OnDeviceResizing);
protected void OnDeviceLost(object sender, EventArgs e)
if(this._line != null)
this._line = null;
I've tried to comment out all the event handlers but the Reset one (I use those delegates to print out "Hello, now I'm disposing/resizing/losing etc..." :-) ) and it happens anyway... If I don't use any line at all, the same problem occurs for Fonts... The same exception but applyed to the Direct3D.Font objects I have... So it really seems like there is something wrong disposing the GDI stuff? The approach I use to Dispose those element is the same one I've explained above... Is there any known issue that can cause this behavior?
Even if I commnt out the Dispose() calls, it happens... To avoid this exception, the only thing I can do is not to use Fonts or Lines. Btw The application runs ok, so I think it is just some disposing problem...
ZMan ha scritto:Do you call Dispose yourself on the line object? If so then the Finalzer won't be called when you quit.
"Giorgio Tino" <giorgio.tino@xxxxxxxxxxxx> wrote in message news:eq4D53PiHHA.4596@xxxxxxxxxxxxxxxxxxxxxxxHi,
I've got a problem using the Line class. Everything seems to work fine, but whenever I close my application, I always get this exception:
System.NullReferenceException was unhandled
Message="Object reference not set to an instance of an object."
at Microsoft.DirectX.Direct3D.Line.OnParentLost(Object sender, EventArgs e)
at System.EventHandler.Invoke(Object sender, EventArgs e)
at Microsoft.DirectX.Direct3D.Device.raise_DeviceLost(Object i1, EventArgs i2)
Any idea about it? Is the Finalize/Dispose called more than once? I've been trying to override all the Lost, Disposing methods, checking if the Line had already been Disposed and so on... My code seems to work fine, but sometimes after I've Disposed everything managing the Device Lost events, this exception occurs...
- Next by Date: Searching for installed filters
- Next by thread: Searching for installed filters