Setting default debug commandline arguments by cod

2019-08-12 01:06发布

There is a way to set the default debug commandline arguments or the default application arguments without setting the arguments in the Debug tab of the project settings?

I'll mean if I can do something like this:

Module Main

#If DEBUG Then
  ' Debug Commandline arguments for my application:
  My.Application.CommandLineArgs = "-Sleep 5 -Interval 50 -Key CTRL+C"
#End If

...Sub main()
   GetArguments() ' A function wich gets the arguemnts that I've set.
...etc...

End module

1条回答
SAY GOODBYE
2楼-- · 2019-08-12 02:02

You can create a class that will abstract your other code from command line. For debug compilation it will return fixed string, otherwise it will return real Enviroment.CommandLine.

public static class CommandLineHelper
{
  public static string GetCommandLine()
  {
   #if DEBUG
     return "my command line string";
   #else
     return Enviroment.CommandLine;
   #endif
  }
}
查看更多
登录 后发表回答