I am having a problem with a C# 20008 windows application not finishing executing and I am trying to determine how to resolve the issue. Initally a C# 2010 console application was written to call a C# 2008 console application Which in turn calls a web
service. I changed both of these applications to be windows application since I did not want the dos pop up windows.
The problem is the called C# 2008 windows application never finsishes executing. The process stays in memory. The code listed below is part of the code from the C# 2010 application.
private static Logger logger = LogManager.GetCurrentClassLogger();
try
{
Process eProcess = new Process();
strConsoleAppLocation = ConfigurationManager.AppSettings["client_location"];
String Process_Arguments = null;
eRPT_Process.StartInfo.UseShellExecute = false;
eRPT_Process.StartInfo.FileName = strConsoleAppLocation;
Process_Arguments = " 1 CLI";
eProcess.StartInfo.Arguments = Process_Arguments;
eProcess.Start();
eProcess.WaitForExit(1800);
Process_Arguments = null;
eProcess.StartInfo.UseShellExecute = false;
Process_Arguments = " 2 TIM";
eProcess.StartInfo.Arguments = Process_Arguments;
eProcess.Start();
eProcess.WaitForExit(1800);
eProcess.Dispose();
Process_Arguments = null;
}
catch (Exception e)
{
logger.Error(e.Message + "\n" + e.StackTrace);
}
I know that C# 2008 app never finishes by looking at processes in memory. In addition if I change the line of code to the following: eProcess.WaitForExit();, the application never returns to the called program.
In the C# 2008 called application, the last line of code that is executed is the following: Environment.Exit(1);
Thus to resolve this problem, I have the following questions:
1. If you have recommendations on how I can change the code I listed above, would you let me know what your recommendations are?
2. Since these 2 programs are in production right now, I am wondering if you have suggestions on how I can resolve this problem for a 'bandaid' fix? Is there a way that I can just stop the C# 2008 process that is running when the C# 2010 program finishes executing? Is there a way to make the C# 2008 application kill its own process when it
has finished executing? If so, can you show me code on how to solve this problem?
3. For the long term fix, can you tell me how to determine why the C# 2008 process does not stop and how I can fix it? I would use profiler, however my company only has the professional version of visual studio 2010. thus can you tell me what your recommendations are?
Loading
VulpesPosted Feb 17, 2013, 5:04 PM
dcPosted Feb 16, 2013, 5:36 PM
I have the following additional comments/questions:
1. For your comment, "To make sure that the Process object still exists, you need to store it in a private field of the main form rather than as a local variable and not call Dispose() on it in the meantime.
I am not exactly certain what you are referring to?
Are you saying that if I put the following code in the driver program, '"if (!eProcess.HasExited) eProcess.Kill();",", that I should not dispose of the objects in the C# 2008 program?
2. Since I think the problem is some connection to the web service I am wondering what you suggest I try and/or look for?
To call the web service there are two objects that are created called a 'proxy' and a 'helper' class.
Thus I am wondering if I do one or more of the following, that would solve my problem:
a. When the process to access the web service has finished, I execute the following
b. proxy.dispose();
c. helper.dispose();
d. object being passed between main program and proxy, call the dispose method.
e. set all those object listed above to null,
f. possibly run the Environment.Exit(1); code at this point.
What is your opinion?
3. I am assuming my problem is how the application connects and/or unconnects to the web service it calls. The program was iniitally written by the contract shop that has the web service. This contract shop that wrote their appliation in Java said they just fixed their problem that releases all the connections from their side. Would this affect me some how?
Are there other things I can be looking for to see what is causing the problem?
VulpesPosted Feb 16, 2013, 4:02 PM