I need to call a method from an exe file
ProcessStartInfo startInfo = new ProcessStartInfo(@"exeParser.exe");
startInfo.WindowStyle = ProcessWindowStyle.Normal;
startInfo.CreateNoWindow = false;
startInfo.RedirectStandardOutput = true;
startInfo.UseShellExecute = false;
startInfo.Arguments = ??
I don’t know how to call a method and pass parameters
Any help please??
The executable is mine but I’m having trouble using the things in a web app so I thought it would be better to call it as a process
Thanks
Executables only have one entry point usually called “Main”.
To call a specific method the application would have to expose a command line argument (or several) for the method name and its arguments. This would mean changing the application to interpret those arguments and call the appropriate method.
You will need to modify your “exeParser” to accept arguments and then act on those.
For example you’d could add:
Then parse this to get the name and list of arguments.
If you only have one or two methods you could hardcode the switch:
If you have more or want to make the code more generic then you’d need to use reflection to get the method and call it.