2 Replies - 4601 Views - Last Post: 31 May 2010 - 08:17 AM Rate Topic: -----

#1 Albert Pinto  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 24
  • Joined: 16-May 10

Cannot Access a Disposed Object

Posted 30 May 2010 - 10:25 PM

Hi....I know this might be a simple query, but its troubling me a lot.
I have Form 1 with a button on it, I'm trying to open another form (Form 2) with that button click.
I have created an instance of this form and then I used Show() function.
While Executing, When I click the button, the form 2 is displayed, I closed it and then again clicked the button, at this point, it gave me an Error " Cannot Access a Disposed Object ".
Everytime, I have to close the application and then execute it again.


Please Help, I'm stuck.

Is This A Good Question/Topic? 0
  • +

Replies To: Cannot Access a Disposed Object

#2 chrixko  Icon User is offline

  • D.I.C Head

Reputation: 16
  • View blog
  • Posts: 63
  • Joined: 25-November 08

Re: Cannot Access a Disposed Object

Posted 30 May 2010 - 11:36 PM

Please show us your Code. I think you are using the same instance every time.
Be sure to create a new Instance everytime you call the Show() Function.
Was This Post Helpful? 0
  • +
  • -

#3 Albert Pinto  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 24
  • Joined: 16-May 10

Re: Cannot Access a Disposed Object

Posted 31 May 2010 - 08:17 AM

Hi, My Problem is solved.....

Actually I was declaring the variable before the button click event



Dim ab As New CompanyClientDetails
Private Sub CompanyClientDetailsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CompanyClientDetailsToolStripMenuItem.Click

ab.Show()
End Sub


Then I declared it inside the click event

Private Sub CompanyClientDetailsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CompanyClientDetailsToolStripMenuItem.Click
Dim ab As New CompanyClientDetails
ab.Show()
End Sub

And it worked fine.....
Thanx.............
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1