问题描述
我正在尝试从另一个wpf应用程序调用一个wpf应用程序.调用wpf应用程序进行调用
I am trying to invoke one wpf application from another wpf application. The invoking wpf application makes the call
ProcessStartInfo BOM = new ProcessStartInfo();
BOM.FileName = @"D:\WPFAPPLICATION.exe";
BOM.Arguments = temp;
Process.Start(BOM);
现在,在调用的应用程序中,我尝试检索使用
传递的参数
Now in the invoked application, I try to retrieve the argument passed using
string arguments =Process.GetCurrentProcess().StartInfo.Arguments;
但是,参数未传递.为什么会这样?
我还在以下位置尝试了一种替代方法:
However the arguments are not passed. why is this??
I also tried an alternative method where in:
public partial class App : Application
{
public static String[] mArgs;
private void Application_Startup(object sender, StartupEventArgs e)
{
if (e.Args.Length > 0)
{
mArgs = e.Args;
}
}
}
}
我也尝试过:
I have also tried:
string[] args = Environment.GetCommandLineArgs
但是,这也不起作用!!!请帮忙!
However this did not work either!!! Please HELP!!
推荐答案
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim psnfo As String
Dim strbuilder As New StringBuilder
Dim arg As String
For Each arg In Environment.GetCommandLineArgs()
strbuilder.AppendLine(arg)
Next
psnfo = strbuilder.ToString
TextBox1.Text = "Args: " & psnfo.ToString
End Sub
代码返回:
Args:C:\ Testapp1.exe
temp
它将返回传递给它的两个参数.
您的代码似乎没有将args视为数组或一组项目.
希望对您有所帮助.
The code returns:
Args: C:\Testapp1.exe
temp
It will return both args passed to it.
your code does not appear to treat the args as an array or group of items.
Hope this helps some.
这篇关于在WPF应用程序中使用process.start调用另一个WPF应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!