Where should objects be instantiated in a multi windows form application

Apr 20 2008 7:15 AM

Hi there, hope i have posted this in the correct place.

Any way im quite new to programming and I am having a few problems with an application i am king for work.  I have got a program that has 2 (soon to be more) forms.

The first form is a login form and the second is the actul user interface form.

What i want to happen is that when a person uses the logon form it will instantiate an object storing there user credentials and accessrights to the application.

The problem is that I am unsure where to instantiate this object as currently it is instantiated on the login form but then there are security and scope issues for accessing this object from the second form.

What i am trying to acheive is having a muti tier application where the gui objects are interacting witht the objects in the domain objects tier, to do this however these objects need to be aliver for the life of the program (even when forms are cloesed) and available to all of the forms.

Hope this makes sense

Andy edwards