title: Where should I initialize the user account of my WPF application?
body: <p>I'm developing a WPF app used by multiple persons on a network.
  On startup I want to get the user name from <code>Environment.UserName</code> and retrieve the user account from my database, then create a <code>User</code> object.</p>
  
  <p><strong>Where should I do the user initialization?</strong> It seems logical to add a member <code>User currentUser</code> to the <code>Application</code> and do the initialization in the <code>Main()</code> method, for example: </p>
  
  <pre><code>public class App : Application {
      public User CurrentUser {
          get; private set;
      }
      private Database database = new Database();
  
      public static void Main() {
          App app = new App();
          CurrentUser = database.getUser(Environment.UserName);
          app.InitializeComponent();
          app.Run();
      }
  }
  </code></pre>
  
  <p>However <strong>I'm having doubts since the <code>Main()</code> is auto generated in WPF.</strong></p>