在WPF应用程序中使用process.start调用另一个WPF应用程序 [英] Using process.start in a wpf application to invoke another wpf application

查看:63
本文介绍了在WPF应用程序中使用process.start调用另一个WPF应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从另一个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!!

推荐答案

我发现了一个网页,该网页显示了从C#转换为VB.Net的版本. http://www.vbdotnetheaven.com/uploadfile/mahesh/access -command-line-arguments-in-VB-Net/ [
I found a web page that showed a version that was converted from C# to VB.Net
http://www.vbdotnetheaven.com/uploadfile/mahesh/access-command-line-arguments-in-VB-Net/[^]

Ive tried this in VB.Net and it works

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应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆