I have developed some backend console apps which are supposed to run on the server.
They are called Server Process and Server Agent. The Server Process always create instances of server agents (as a process) time by time, here is the code for calling server agent
private static void CreateUpdatedBookingAgent(UpdatedBooking oUpdatedBooking)
{
try
{
//Run the Console App
string command = @"C:\ServerAgentConsole.exe";
string args = ("UpdatedBooking " + oUpdatedBooking.MeetingKey + " " + oUpdatedBooking.ServiceAccountEmail.Trim() + " " + oUpdatedBooking.ServiceAccountPassword.Trim()
+ " " + oUpdatedBooking.ServiceAccountEmail.Trim()+ " " + oUpdatedBooking.MailBoxOwnerEmail.Trim() + " " + oUpdatedBooking.Method.Trim()
+ " " + oUpdatedBooking.ExchangeURL + " " + oUpdatedBooking.ApiURL + " " + oUpdatedBooking.Subject + " " + oUpdatedBooking.Location
+ " " + oUpdatedBooking.StartTime + " " + oUpdatedBooking.EndTime).Trim();
Process process = new Process();
process.StartInfo.FileName = command;
process.StartInfo.Arguments = args;
process.EnableRaisingEvents = true;
process.Exited += new EventHandler(processExitedUpdatedBooking);
process.Start();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
My question is:
Can I use .NET remoting for this, I mean is it a good way of doing this?
If not, is there a better way of passing the data (arguments) to the server agent?
The server and client both must be console application. According to my knowledge, the I can not get a benefit from WCF in that case. Am I correct?
While WCF is quite rightly the best way to go, I have recently faced a similar issue to what you are facing. My scenario was the need to call a .NET 4.5 console app from a .NET 2 Winforms app.
The data being passed was trivial and I deemed it easier to simply serialise the data to disk and pass the filename of the serialised data to the .NET 4 app. The .NET 4 app retrieves the data from the filename it receives when it is called, and removes the file.
I'm not saying it's pretty, but it is effective and may be worth considering.