Home > database >  PB call c # to write the EXE, how to acquire the string value returns to its execution procedures?
PB call c # to write the EXE, how to acquire the string value returns to its execution procedures?

Time:10-14

I didn't contact with PB, but do in the project involves: PB call c # to write the EXE, the c # EXE is written by our company, PB is another company, need to let the other side to call our EXE, XML input parameters specified in the call time, after performing the EXE, PB EXE need to get to his return values, XML format in the calling process, our company will have some business process form interaction,
Ask ace to help solve!
C # code EXE service execution procedures (ConsoleApp. EXE) of sample code is as follows:
The static void Main (string [] args)
{
String procName=System. Diagnostics. Process. GetCurrentProcess (). The ProcessName;
File. AppendAllText (" D: \ \ systemtool TXT ", procName + "\ n");
If ((System. Diagnostics. Process. GetProcessesByName (procName). GetUpperBound (0)==0)
{
File. AppendAllText (" D: \ \ systemtool TXT ", "Bussiness handle" + "\ n");
//receiving over XML format string parameter
String paramXML="";
if (! String. IsNullOrEmpty (args [0])
{
ParamXML=args [0];
File. AppendAllText (" D: \ \ systemtool TXT ", "XML Input parameters:" + paramXML + "\ n");
XmlDocument oXmlDoc=new XmlDocument ();
Try
{
OXmlDoc. LoadXml (paramXML);
XmlNode root=oXmlDoc. DocumentElement;
XmlNodeList nodes=root..childnodes;
Foreach (XmlNode node in nodes)
{
File. AppendAllText (" D: \ \ systemtool TXT ", node. The Name + "- & gt;" + node. The InnerText + "\ n \ n");
}

//call other business form code
.

}
The catch (Exception error)
{
File. AppendAllText (" D: \ \ systemtool TXT ", "the Exception error - & gt;" . + error Message + "\ n");
Throw new Exception (error Message);
}
The finally
{
OXmlDoc=null;
}
}
//the return value
String returnParam="& lt; Root> 1 & lt;/RetValue> ";

The Console. Write (returnParam);//returns the value written to the standard of the console output,
}

C # call EXE executable program sample, as follows:
The Process of p=new Process ();
P. tartInfo. UseShellExecute=false;
P. tartInfo. RedirectStandardOutput=true;
//external Console service routine physical path
P. tartInfo. FileName=@ "F: \ ConsoleApp exe";
P. tartInfo. CreateNoWindow=true;
//start parameter
P. tartInfo. The Arguments="& lt; Root> 0 ";
P. tart ();
P.W aitForExit ();
//the return value
String returnValue=(https://bbs.csdn.net/topics/p.StandardOutput.ReadToEnd);

CodePudding user response:

Please help write a test through the source code, thank you very much, hurry!!

CodePudding user response:

Why send 2 times? Please refer to: http://blog.csdn.net/nocry115/article/details/52851722

CodePudding user response:

refer to the second floor nocry115 response:
why send 2 times? Please refer to: http://blog.csdn.net/nocry115/article/details/52851722


Provided for reference, but I need to call EXE, rather than the DLL,

CodePudding user response:

Write a text file, I also send 2 times

CodePudding user response:

reference 4 floor zjl8008 response:
write a text file, I also send two


Can't use database and text

CodePudding user response:

Redirects the output to a file, try the following code

Run (" f: \ consoleapp exe '& lt; Root> 0 '& gt;> C: \ 111. TXT ")

Then pb in open c: \ 111. TXT for processing
  • Related