Click here to Skip to main content
12,457,579 members (60,030 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# .NET WPF Process
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!!
Posted 16-May-12 18:02pm
Updated 16-May-12 18:55pm
v2
Comments
Member 10290238 11-Oct-13 22:56pm
   
Process.Start("http://localhost:50613/IAlert%20Website/User/readmore.aspx?artid=id&usid=userid");is it correct?

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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

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.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160826.1 | Last Updated 17 May 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100