通过 Cmd 传递参数时出现 NullArgumentException

NullArgumentException when Passing Arguments through Cmd

我已经使用 VB.Net 创建了一个 Windows 应用程序,它使用 Sub Main 来确定应用程序是否应该 运行 一个特定的进程或者只是作为用户交互的表单打开。除了我尝试通过 Windows Task Scheduler 安排我的应用程序时,一切都很好。我一直得到 0xFF 的结果代码。然后,我尝试 运行 直接通过命令提示符连接我的应用程序。执行此操作时,我收到 System.ArgumentNullException 错误。所提供的其他信息非常缺乏,所以我很难确定我的问题到底出在哪里。我可以使用 System.Diagnostics.Process 命令从表单 运行 我的应用程序并将参数传递给它。我也可以通过在应用程序属性的“调试”选项卡中输入命令行参数来成功 运行 它。下面是我的代码的概要。我正在使用命令行解析器库来破译参数。任何帮助或指导将不胜感激

Imports CommandLine
Imports CommandLine.Text

Module Startup

    Public Sub Main()
        Dim Args() As String = Environment.GetCommandLineArgs
        Dim Options As New Arguments
        Dim Parser As New Parser

        If Parser.ParseArguments(Args, Options) Then
          ' Run application
        Else
          ' Open windows form
        End If
    End Sub

    Public Class Arguments
        <[Option]("p", "process", Required:=True)> Public Property ProcessOption As String
        <[Option]("r", "run", Required:=True)> Public Property RunOption As String
        <[Option]("d", "date", Required:=False, DefaultValue:=Nothing)> Public Property DateOption As Date
        <[Option]("u", "user", Required:=False, DefaultValue:="")> Public Property UserOption As String
    End Class

End Module

我能够 运行 使用调试器在我的测试机器上进行此操作,并找到了我的问题所在。它实际上与命令提示符传递的参数无关。这是我打的另一个子电话。我将不得不玩它,如果我无法弄清楚,我会提出另一个问题。谢谢您的帮助。