views:

111

answers:

2

I have an app with login/logout functionality. When the user logs out, I want to completely reset all classes and variables (I use static classes so this makes the problem even harder).

I have decided that its best to just leave the resetting and do a total reload of the app - the user wouldn't know the difference and it would clear any possible breadcrumbs.

So I would like some ideas on either of the following (whichever is best/easiest)

1) Reload the app by closing the process itself and restarting 2) Keep the app running and reset all data and variables (including windows) - possibly by AppDomain.Unload / Load or some combo

Any advice?

A: 

If option 1 is a valid option, then it is by far the easiest, so that is what I would do.

Using AppDomains as a sandbox is not without its problems as you can see from this question: http://stackoverflow.com/questions/219594/net-whats-the-best-way-to-implement-a-catch-all-exceptions-handler

Brian Rasmussen
I am going to test the following 2 line solution, will report back: System.Windows.Forms.Application.Restart(); Application.Current.Shutdown();
bluebit
+1  A: 

You probably don't want to hear this, but you're running into these issues now because the original design was most likely out of whack. Storing data related to a user session in a static context is usually not the best way to go about things.

Jon Seigel