Is there any way to know in C# the type of application that is running.
Windows Service ASP.NET Windows Form Console
I would like to react to the application
To check for a Forms, WPF, WCF or Console application:
if (System.Windows.Forms.Application.OpenForms.Count > 0)
{
return ApplicationType.WindowsForms;
}
if (System.Windows.Application.Current != null)
{
return ApplicationType.Wpf;
}
if (System.ServiceModel.OperationContext.Current != null)
{
return ApplicationType.Wcf;
}
try
{
int windowHeight = Console.WindowHeight; // an exception could occur
return ApplicationType.Console;
}
catch (IOException)
{
}
return ApplicationType.Unknown;