title: Determine if app is WinForms or WebForms
body: <p>Is there a way to determine if running app is WinForms or Web at runtime?</p>
  
  <p><strong>[Edit]</strong></p>
  
  <p>Is there actually a problem if I reference both <code>System.Web</code> and <code>System.Windows.Forms</code> in my class library?</p>
  
  <p><strong>[Summary]</strong> (so far)</p>
  
  <p>What I've learned so far:</p>
  
  <ul>
  <li><code>HttpContext.Current</code> is <code>null</code> if checked in an async thread, so it cannot reliably be used in a helper method. <code>HttpRuntime.Cache</code> doesn't really help since I am not looking for the cached context at all (or am I missing something here?).</li>
  <li>on the other hand, <code>System.Reflection.Assembly.GetEntryAssembly()</code> seems to return <code>null</code> in web apps, and non null in WinForms. Should that be taken for granted? There should be more "hacks" like this, so which one to use?</li>
  <li>referencing both <code>System.Web</code> and <code>System.Windows.Forms</code> in a helper library should be fine, according to <a href="https://stackoverflow.com/questions/2957365/referencing-both-system-web-and-system-windows-forms">this thread</a>.</li>
  </ul>