Form gets disposed somehow
Posted
by mnn
on Stack Overflow
See other posts from Stack Overflow
or by mnn
Published on 2010-05-30T10:32:57Z
Indexed on
2010/05/30
10:42 UTC
Read the original article
Hit count: 375
I have a client-server application, in which I use classic Sockets and threads for receiving/sending data and listening for clients.
The application works fine, but after some random time I get the ObjectDisposedException:
System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'MainForm'.
at System.Windows.Forms.Control.MarshaledInvoke(Control caller, Delegate method, Object[] args, Boolean synchronous)
at System.Windows.Forms.Control.Invoke(Delegate method, Object[] args)
at System.Windows.Forms.Control.Invoke(Delegate method)
That code is called from client Socket thread and I use Invoke() method to run the code on UI thread.
I'm sure that I don't manually dispose the form nor using Close() (form is closed by user clicking Close button), so I don't know what could cause its disposing.
© Stack Overflow or respective owner