问题描述:

I am using a ASP.net webform application to run an existing console application which get all records from DB and send them through a third party WCF service. Locally everything is working fine. When I run the application it opens the console, gets the records and sends them. But now I pushed my files over to Test server along with the exe file and related config files. But when I access the application through the browser (test url) I get the same error message time and again and I don't see the console window. Sometimes everything works fine but never two times in a row.

The error message is:

"There was no end point listening at '.....svc' that could accept message. This is often caused by incorrect address or soap action.

System.net.webexception. Remote name could not be resolved

at System.Net.HttpWebRequest.GetRequestStream

at System.ServiceModel.Channels.HttpOutput.Webrequest.HttpOutput.GetOutputStream()

The code I have used in the webform to call console application is:

ProcessStartInfo p = new ProcessStartInfo();

p.Arguments = _updateNow.ToString();

p.FileName="something";

p.UseShellExecute = false;// tried true too without luck

Process.Start(p);

Error message denotes "there is no end point" and sounds like there is problem with the WCF service but if I double click the executable in Test there is no problem. What could be the possible problem or should I redo the console application functionality to my main webform application?

Update: After adding Thread.Sleep(3000) after Process.Start(p), I'm having no problem. So seems like main application is not waiting for the batch process to complete. How to solve this problem?

网友答案:

It seems like there is a short delay between starting the console application and the WCF web service becoming initialise and available to use - this is to be expected.

You could either:

  • Work around the issue using Thread.Sleep() and possibly with a couple of catch - retry blocks.
  • You could have the console application report to the creating process when it is ready to recieve requests (for example by having it write to the standard output and using redirected streams).

However at this point I'd probably reconsider the architecutre slightly - starting a new process is relativley costly, and on top of that initialising a WCF serice is also relatively costly too. If this is being done once per request then as well as the above timing issues you are also incurring performance penalties.

Is it not possible to change the architecutre slightly so that a single external process (for example a Windows service) is used for all requests instead of spawning a new process each time?

相关阅读:
Top