dc

dc

  • NA
  • 663
  • 0

C# calling an executable problem

Oct 3 2012 9:46 AM
I have a C# 2010 console application that calls a web service where I am having a problem. The line of code that is commented out for the strConsoleAppLocation string field works correctly when I run the application from my workstation. However when the application is deployed the line of code that refers to strConsoleAppLocation path is changed, I get an error on the line of code, " Process1.StartInfo.Arguments = Process_Arguments;".

When the application is deployed, I make certain the executable is located in the directory path: \\server1\\DEV\\Ftest\\Esample.exe.

Here is the code I am referring to; 
protected void add_to Web_service()
  { 
 
  String strConsoleAppLocation = "\\server1\\DEV\\Ftest\\Esample.exe";
  //String strConsoleAppLocation = "C:\\Users\\me\\Documents\\Visual Studio 2010\\Projects\\bin\\Debug\\Esample.exe";";
  String strEncryptedValue = "encrypted";
  String strWebServiceurl = "https://test/test1/TWebService";
  Process Process1 = new Process();
  String Process_Arguments = null;
  Process1.StartInfo.UseShellExecute = false;
  Process1.StartInfo.FileName = strConsoleAppLocation;
  Process1_Arguments = strEncryptedValue + " " + strWebServiceurl + " 798 ";
  Process1.StartInfo.Arguments = Process_Arguments;
  Process1.Start();
 
  }

Due to what I mentioned above, I have the following questions:
1. Can you tell me what to do to resolve this issue for now?
2. When this application goes to production, can you tell me and/or point me to a reference to display the preferred method
of how the Esample.exe executable should be called?

Answers (2)