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.Currentisnullif checked in an async thread, so it cannot reliably be used in a helper method.HttpRuntime.Cachedoesn'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 returnnullin 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.WebandSystem.Windows.Formsin a helper library should be fine, according to this thread.