473,765 Members | 1,964 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

System.ObjectDi sposedException : Cannot access a disposed object.

36 New Member
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.ObjectDi sposedException : 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.EventArg s) 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(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
End Sub
End Class

i wrote this code behind f1.vb

Public Class f1

Private Sub f1back_Click(By Val sender As System.Object, ByVal e As System.EventArg s) Handles f1back.Click
first.back.Show ()
first.back = first.main1(fir st.back)
End Sub

Private Sub f1_FormClosed(B yVal sender As Object, ByVal e As System.Windows. Forms.FormClose dEventArgs) Handles Me.FormClosed

End Sub

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

End Sub
Private Sub f1next_Click(By Val sender As System.Object, ByVal e As System.EventArg s) Handles f1next.Click
Me.Close()
If (first.f2dchk.C hecked = True) Then
first.back = first.main1(Me)
f2.Show()
Else
If (first.f3dchk.C hecked = 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(By Val sender As System.Object, ByVal e As System.EventArg s) Handles f2back.Click
first.back.Show ()
first.back = first.main1(fir st.back)
End Sub
Private Sub f2_FormClosed(B yVal sender As Object, ByVal e As System.Windows. Forms.FormClose dEventArgs) Handles Me.FormClosed

End Sub

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

End Sub
Private Sub f2next_Click(By Val sender As System.Object, ByVal e As System.EventArg s) Handles f2next.Click

Me.Close()
If (first.f3dchk.C hecked = 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(B yVal sender As Object, ByVal e As System.Windows. Forms.FormClose dEventArgs) Handles Me.FormClosed

End Sub

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

End Sub

Private Sub f3back_Click(By Val sender As System.Object, ByVal e As System.EventArg s) Handles f3back.Click
first.back.Show ()
first.back = first.main1(fir st.back)
End Sub


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

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

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

Similar topics

3
15323
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 written a conversion? TIA, Matt
0
339
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 Stack Trace at System.Net.TlsStream.InnerWrite(Boolean async, Byte buffer, Int32 offset, Int32 size, AsyncCallback asyncCallback, Object asyncState) at System.Net.TlsStream.BeginWrite(Byte buffer, Int32 offset, Int32 size, AsyncCallback...
0
3788
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 ad-infinitum). So can you put a try catch handler in the Disconnect_Click handler to trap the exception so you can, say, write the exception yttace out to a file. You need to know which obejct is generating the exception, whether it is one of your Windows Forms...
5
8523
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 System.Threading.Timer.Change(Int32, int32) at Systems.Timers.UpdateTimer() at System.Timers.Timer.set_Interval(double value)
0
2600
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 information: Cannot access a disposed object named "System.Net.Sockets.NetworkStream". We are making a webmethod call that gets back a simple ID
9
17768
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 nothing special: EventType : clr20r3 P1 : app.exe P2 : 1.0.0.0 P3 : 24 P4 : app P5 : 1.0.0.0 P6 : 24 P7 : 11d P8 : 0 P9 : system.nullreferenceexception
3
8753
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 ExportDialog(); export.Show();
2
3447
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 when we are making a web service call to an external system (within our corporate n/w). The method is POST and the URL is over HTTPS.
5
4981
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 exception. An exception of type 'System.ObjectDisposedException' occurred in System.Windows.Forms.dll but was not handled in user code Additional information: Cannot access a disposed object.
0
9399
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10161
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10007
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8831
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7378
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5275
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3924
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3531
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.