Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I am trying to invoke one wpf application from another wpf application. The invoking wpf application makes the call
C#
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:

C#
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:
C#
string[] args = Environment.GetCommandLineArgs

However this did not work either!!! Please HELP!!
Posted
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

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

VB
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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900