Wednesday, June 3, 2009

INSTANCE OF REFERENCE IS DISPOSED

Some times we have a situation where we dispose the reference instance and then later on we try to use it and it gives us an exception

"Cannot access a disposed object".

The simple solution of the above problem is that you first check that either the instance of the reference is not disposed. If it is disposed then create a new instance of the reference and to check that either the instance of the reference is alive or not, we simple write the following code

if frm.IsDisposed()=true then
frm=new form1
end if

That's all....

Enjoy the world of Programming.

No comments: