Benutzer mit den meisten Antworten
how to make c# form application to be able to run with parmeters from cmd?

Frage
-
Hi Together
I have a form application and would like to be able to run it as form application but also from cmd giving some Parameters.
I tried following down below but i dont get any output result in cmd.
It seems to be executed but no Output.
This is how my Programm main() method Looks like.
If i run it with Parameters in visual Studio it is going into the else Statement and form is not started.
Whisch is ok.
If i start exe from cmd with Parameters i dont get any Output.
Do you know what is the Problem?
Thanks in advanc for yoour help.
static void Main(string[] args) { args = Environment.GetCommandLineArgs(); if(args.Length ==1) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } else { foreach (Object obj in args) { Console.WriteLine(obj); } Console.WriteLine("We'll run as a console app now"); Console.Read(); } }
Antworten
-
Hi,
in der Regel würde ich hier zwei Anwendungen und eine Library vorschlagen.
Die gesamte Logik wird dann in die Library ausgelagert und die Anwendungen selbst sind für die Aufrufe und die Ausgaben zuständig.
Gruß, Stefan
Microsoft MVP - Visual Developer ASP/ASP.NET (2001-2018)
https://www.asp-solutions.de/ - IT Beratung, Softwareentwicklung, Remotesupport- Als Antwort vorgeschlagen Dimitar DenkovMicrosoft contingent staff, Administrator Montag, 28. Januar 2019 06:25
- Als Antwort markiert todomati Dienstag, 29. Januar 2019 09:31
Alle Antworten
-
Hi,
in der Regel würde ich hier zwei Anwendungen und eine Library vorschlagen.
Die gesamte Logik wird dann in die Library ausgelagert und die Anwendungen selbst sind für die Aufrufe und die Ausgaben zuständig.
Gruß, Stefan
Microsoft MVP - Visual Developer ASP/ASP.NET (2001-2018)
https://www.asp-solutions.de/ - IT Beratung, Softwareentwicklung, Remotesupport- Als Antwort vorgeschlagen Dimitar DenkovMicrosoft contingent staff, Administrator Montag, 28. Januar 2019 06:25
- Als Antwort markiert todomati Dienstag, 29. Januar 2019 09:31