【问题标题】:Passing arguments are empty传递参数为空
【发布时间】:2016-05-02 22:09:11
【问题描述】:

我将一些参数从 WPF 应用程序传递给这样的 WinForm 应用程序。

int processID = Process.GetCurrentProcess().Id;

Process p = new Process();
p.StartInfo.FileName = FileManager.AppDirectoryName + "\\" + winformApp;
p.StartInfo.Arguments = string.Format("Param1={0}", processID );
p.Start();

但在其他应用程序中我看不到任何参数。

[STAThread]
static void Main()
{
 // Get start arguments 
 var process = Process.GetCurrentProcess();
 var args = process.StartInfo.Arguments; // It is empty. Why is it??

有什么线索吗?

【问题讨论】:

  • 试试var args = Environment.GetCommandLineArgs()
  • Derp,nm,我在想控制台。不理我。 static void main() 通常没有 string[] args 参数吗?

标签: c# .net process processstartinfo


【解决方案1】:
Process.GetCurrentProcess()

返回

与运行调用应用程序的进程资源相关联的新进程组件。

这个新组件将有一个空的 startinfo 成员。只需使用

Environment.GetCommandLineArgs()

相反。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-05-07
    • 2012-05-08
    • 2019-11-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多