2016-08-02 69 views
0

打开我的应用程序的代码。并将参数我的应用程序:从另一个应用程序获取字符串数组

Process.Start("C:\\Users\\Laca\\Documents\\Visual Studio 2013\\Projects\\SMT_Previous_StationsChecker_Before_ICT\\SMT_Previous_StationsChecker_Before_ICT\\bin\\Debug\\SMT_Previous_StationsChecker_Before_ICT.exe", "test"); 

我试图对其进行处理:

public partial class MainForm : Form 
{ 

    //public string[] ict_barcodes { get; set; } 
    class ParamHolder 
    { 
     public static string[] Params { get; set; } 
    } 
    public MainForm(string[] ict_barcodes) 
    { 
     InitializeComponent(); 
     ParamHolder.Params = ict_barcodes; 
    } 

    private void MainForm_Load(object sender, EventArgs e) 
    { 

     try 
     { 
      MessageBox.Show(ParamHolder.Params[0]); 
     } 
     catch (Exception ex) { MessageBox.Show(ex.Message); } 

    } 
} 

但没有奏效。我收到以下错误:

Application.Run(new MainForm()); ->>Error 1 'SMT_Previous_StationsChecker_Before_ICT.MainForm' does not contain a constructor that takes 0 arguments C:\Users\Laca\Documents\Visual Studio 2013\Projects\SMT_Previous_StationsChecker_Before_ICT\SMT_Previous_StationsChecker_Before_ICT\Program.cs 18 29 SMT_Previous_StationsChecker_Before_ICT

任何想法?

+0

这是一个有点不清楚是什么你要吗。请说明你的问题。你在哪里创建“MainForm”? – Marusyk

+0

因此,另一个程序打开我的程序,并发送给我的程序一个字符串,我必须处理它,多数民众赞成但它不起作用 –

+0

该代码在哪里?请参阅[如何提出问题。](http://stackoverflow.com/help/how-to-ask)并使用您问题上的编辑链接添加其他信息 – Marusyk

回答

0

SMT_Previous_StationsChecker_Before_ICT应用Main方法,你必须添加输入参数,如:

static void Main(string[] args) 

,然后在该方法这个参数传递到MainForm构造

Application.Run(new MainForm (args)); 
+0

非常感谢你的工作 –

+0

很高兴能有帮助 – Marusyk

相关问题