通过代码设置默认的调试命令行参数?(Setting default debug commandlin

2019-10-18 01:13发布

有一种方法来设置默认的调试命令行参数或默认的应用程序参数,而不在项目设置调试选项卡中设置的参数?

我的意思是,如果我可以做这样的事情:

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

Answer 1:

您可以创建一个类,将抽象的其他代码的命令行。 为了调试编译它将返回固定的字符串,否则将返回真正Enviroment.CommandLine。

public static class CommandLineHelper
{
  public static string GetCommandLine()
  {
   #if DEBUG
     return "my command line string";
   #else
     return Enviroment.CommandLine;
   #endif
  }
}


文章来源: Setting default debug commandline arguments by code?