0

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?

Brian Rasmussen
  • 114,645
  • 34
  • 221
  • 317
bluebit
  • 2,987
  • 7
  • 34
  • 42

2 Answers2

2

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
  • 12,251
  • 8
  • 58
  • 92
0

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: .NET - What's the best way to implement a "catch all exceptions handler"

Community
  • 1
  • 1
Brian Rasmussen
  • 114,645
  • 34
  • 221
  • 317
  • I am going to test the following 2 line solution, will report back: System.Windows.Forms.Application.Restart(); Application.Current.Shutdown(); – bluebit Aug 28 '09 at 08:51