473,385 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

System.ObjectDisposedException: Cannot access a disposed object.

36
Hai i am working on vb.net.
In my application I created four forms.Those are first.vb,f1.vb,f2.vb and f3.vb
In firstvb I added 3 checkboxes and a "display" button.The 3 checkboxes are used to display the forms f1,f2 and f3.If first checkbox is checked then it displays the f1 form.Similarly for f2 and f3 also.I kept all this code in the display button click event.In f1.vb,f2.vb and f3.vb I added back and next buttons. I wrote some code to display the previous form into Back button click event of each form. For this I am using a public function main1() in first.vb.If i click on back button at run time, it gets this error System.ObjectDisposedException: Cannot access a disposed object.

This is the code behind first.vb

Public Class first
Public Shared back As System.Windows.Forms.Form
Public Shared Function main1(ByVal f1 As System.Windows.Forms.Form) As System.Windows.Forms.Form
Return (f1)
End Function
Private Sub bdisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bdisplay.Click
Me.Visible = False
If (f1dchk.Checked = True) Then
back = main1(Me)
f1.Show()
Else
If (f2dchk.Checked = True) Then
back = main1(Me)
f2.Show()
Else
If (f3dchk.Checked = True) Then
back = main1(Me)
f3.Show()
End If
End If
End If

End Sub
Private Sub first_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class

i wrote this code behind f1.vb

Public Class f1

Private Sub f1back_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles f1back.Click
first.back.Show()
first.back = first.main1(first.back)
End Sub

Private Sub f1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed

End Sub

Private Sub f1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub
Private Sub f1next_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles f1next.Click
Me.Close()
If (first.f2dchk.Checked = True) Then
first.back = first.main1(Me)
f2.Show()
Else
If (first.f3dchk.Checked = True) Then
first.back = first.main1(Me)
f3.Show()
End If
End If
End Sub
End Class

I wrote this code behind f2,vb

Public Class f2
Private Sub f2back_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles f2back.Click
first.back.Show()
first.back = first.main1(first.back)
End Sub
Private Sub f2_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed

End Sub

Private Sub f2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub
Private Sub f2next_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles f2next.Click

Me.Close()
If (first.f3dchk.Checked = True) Then
first.back = first.main1(Me)
f3.Show()
End If
End Sub

End Class

I wrote this code behind f3.vb

Public Class f3

Private Sub f3_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed

End Sub

Private Sub f3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

Private Sub f3back_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles f3back.Click
first.back.Show()
first.back = first.main1(first.back)
End Sub


Private Sub f3next_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles f3next.Click
Me.Close()
End Sub
End Class

Can anyone help me?
Dec 24 '07 #1
0 3012

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: MJB | last post by:
I'm getting an IStream back from function xmlHttp.responsestream. I would like to convert this to a System.IO.Stream in order to work with it in my application. Has anyone encountered this and...
0
by: Asaf | last post by:
Hi, When I am doing a POST to a SSL URL I am getting this error on first attempt "Cannot access a disposed object named "System.Net.TlsStream"." After the first attempt all works fine, here is the...
0
by: Richard Blewett [DevelopMentor] | last post by:
In theory there is nothing wrong with the Windows Forms part of your application (using your code as a start I mocked up the app and can happily press the connect and disconnect buttons...
5
by: theinvisibleGhost | last post by:
I'm having a problem that occurs at random in my app. I get an exception "Cannot Access a disposed object" In MSCorLib when calling boolean Change (int32, int32) Stack trace reveals...
0
by: Naveen | last post by:
Hello all, Environment - Winforms app calling into a webservice Exception returned - "A first chance exception of type 'System.ObjectDisposedException' occurred in system.dll" Additional...
9
by: SharpCoderMP | last post by:
i've been experiencing random crashes on some machines running my app. the app never crashed in such way on my dev machine so i'm totally unable to debug this. the error page users get says...
3
by: Martin Pöpping | last post by:
Hello, I´ve a problem with a small line of code. For my Windows Application I designed a form for exporting data into xml files. I´m opening the dialog with: ExportDialog export = new...
2
by: =?Utf-8?B?cmVk?= | last post by:
Hi Friends, We recently deployed our application to production and I am experiencing the below error message. Cannot access a disposed object named "System.Net.TlsStream" The error occurs...
5
by: Brian | last post by:
Hello all. I have a simple application that I was using to test and understand the System.Timers.Timer and noticed that when I stop the application, on occasion, it throughs the following...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.