Form access error when try to use a Form from Project1 in Project2

Thor Vestaberg
Thor Vestaberg used Ask the Experts™
on
I have two project in same solution, where I try to use a form from the other project in this project.

I have added Project1 as en reference in Project2 (Reference to the exe file - Correct? )

And then I try this in a mdicontainer form i Project2:

        Dim ReportFrm As New Project1.Form_report

        ReportFrm.Close()
        ReportFrm.MdiParent = Me
        ReportFrm.WindowState = FormWindowState.Maximized
        ReportFrm.Show()

Then I get this error when try "ReportFrm.Show()" : exception: can't access removed object

What to do ?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Senior Software Engineer
Top Expert 2009
Commented:
Please remove:
ReportFrm.Close()

Open in new window

the code above close and dispose the form ReportFrm. Your code should be:
Dim ReportFrm As New Project1.Form_report

ReportFrm.MdiParent = Me
ReportFrm.WindowState = FormWindowState.Maximized
ReportFrm.Show()

Open in new window

Thor VestabergDeveloper

Author

Commented:
Thanks :-)

So easy, but then again so difficult when your blind :-D
Miguel OzSenior Software Engineer
Top Expert 2009

Commented:
YOu are welcome sometimes we need another pair of eyes that are tired or stressed out

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial