Discovery of winnings or web forms
Any reliable elegant way to determine if the current application is a win-win or web form (or other) application?
We have a generic config class that needs to open either app.config or web.config.
I am currently catching an ArgumentException when trying to OpenExeConfiguration, but it is not very graceful and may mask other issues.
a source to share
You can try to get the process running through Process.GetCurrentProcess()
, maybe you could check Process.MainWindowHandle
not IntPtr.Zero
, or check the process name, or potentially scan the loaded modules of the process. This would have the advantage (I would guess) of not requiring the loading of nodes that are not required by your current execution context (for example, not loading System.Windows.Forms.dll when this application is a web application).
However, this seems inelegant.
a source to share