Is there a way to determine if running app is WinForms or Web at runtime?
[Edit]
Is there actually a problem if I reference both System.Web
and System.Windows.Forms
in my class library?
[Summary] (so far)
What I've learned so far:
HttpContext.Current
isnull
if checked in an async thread, so it cannot reliably be used in a helper method.HttpRuntime.Cache
doesn't really help since I am not looking for the cached context at all (or am I missing something here?).- on the other hand,
System.Reflection.Assembly.GetEntryAssembly()
seems to returnnull
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? - referencing both
System.Web
andSystem.Windows.Forms
in a helper library should be fine, according to this thread.