Hello I have a weird bug in my application.
I have build an c# script which opens a form. Well if I run the .exe from visual studio everything works great but if I run the .exe by doubleclick or from the cmd the program stays for 5-10 seconds and than restarts the form again and stays untill I close the programm. The project is a windows forms application.
My Main looks like this:
static int Main(string[] args)
{
using (StreamWriter w = File.AppendText(@"pathToLog\log.txt"))
{
string currentProject = GetCurrentProject();
if (currentProject == "project")
{
if (args.Length > 0)
{
startType = args[0];
Log("Commandline argument" + args[0], w);
if (startType == "-param1")
{
Log("In param1!", w);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
Log("Out of param1!", w);
return 1;
}
else if (startType == "-param2")
{
//do some stuff
return 2;
}
}
}
return 0;
}
}
What do I miss? Of course I am giving the cmd the right params to start the form.
Aucun commentaire:
Enregistrer un commentaire