I have created an C# application, I need to access to my app in 2 modes:
- GUI:
via mouse or via ms dos console like this:
app.exe
- CommandLine:
via ms dos console like this(without GUI interface):
app.exe -c <some_other_options>
The problem when I configured my application like Windows Application
The console version is not launched. But when I changed it to Console Application
it launched with command line in 2 desired modes but when I launch it via click by mouse I had a black console opened with my gui and when I close the black console, the GUI is also closed.
Is it possible to make my need via c#?
There is my main function:
[STAThread]
static void Main(string[] args)
{
var options = new Options();
var parser = new CommandLineParser(new CommandLineParserSettings(Console.Error));
if (args.Count() != 0)
{
try
{
if (!parser.ParseArguments(args, options))
Environment.Exit(1);
customfunc(options);
Environment.Exit(0);
}
catch (Exception e)
{
System.Console.WriteLine("Fatal error on parsing: " + e.Message);
Environment.Exit(1);
}
}
else
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new frmApp());
}
}