I have a C# 2008 windows/console application that I need to support that never seems to stop running. This application
seems to not release resources also. This application does not close connections also.
Thus can you show me in code, tell me, and/or point me to a reference that will answer the following questions:
1. How can I force a program to stop running?
2. How can I have the application release resources?
3. How can I have the appliction close connections?
4. Of the steps listed above, can you tell me the order of how these ending operations should occur?
Loading
VulpesPosted Feb 7, 2013, 2:09 PM
dcPosted Feb 7, 2013, 1:15 PM
I looked in the 'locals' window and the only thing I was was the parameters that were passed to the application when it first started.
Thus my question, is there other window(s) I can use to see what is open before the application finishes executing?
If there are other windows can you tell me what window(s) to use and give me an order of what is the best debug window to use?
I want to mention the following also:
1. An experienced contract told me I can deploy this application to production in debug mode since it is a low volume application. Could this be a problem? If so, can you tell me how to reoslve the issue?
2. Also when I deploy the C# 2008 application using the setup and deployment methods (not availalbe in vs 2012), I deploy everything? Could this be a problem? If so what should I deploy?
3.This application looks at filenames but does not open the files. Could this be an issue?
VulpesPosted Feb 7, 2013, 11:32 AM
Also, even if they're already closed, calling the Close() method again may not be a problem - it'll just be ignored.
However, I'd look at what happens when the application ends normally and just reproduce that code (or call the appropriate method) before you attempt to end it abnormally.
dcPosted Feb 6, 2013, 10:24 PM
1. How can I tell what the additional connections that could still be open are?
2. How can I tell what connections are still open?
VulpesPosted Feb 6, 2013, 7:22 PM
dcPosted Feb 6, 2013, 4:55 PM
I have the following additional questions:
1. You mentioned the following, "Before calling either of these, I'd try closing all connections manually and releasing unmanaged resources by calling Dispose() on any object still in scope which implements IDisposable.".
Can you show me some code on how to accomplish this goal?
2. This appllication calls a web service. If I use either Application.Exit(); or Environment.Exit(1); , would that affect the connection to the web service? If so, is there other code I should use to solve the problem.
3. This application just went into production a few days ago for my small company. There are messages that the network admin found where the application is trying to write to registry keys. I did not think this application wrote to the registry keys but it must. What can I look for to see how the application is writing to registry keys?
4. Could the registry key problem be due to setting integrated security=true on the database connection? Do you think if the integrated security= false and an sql server application user is setup, would this solve the problem?
5. Overall, what do you think the best solution and can you show me code on how to solve this problem?
VulpesPosted Feb 6, 2013, 3:51 PM
Application.Exit();
and, if that doesn't work:
Environment.Exit(1);
Before calling either of these, I'd try closing all connections manually and releasing unmanaged resources by calling Dispose() on any object still in scope which implements IDisposable.
Managed resources will be cleaned up automatically by the CLR when the application ends.
It's also likely that the operating system will be able to release unmanaged resources (file handles etc) when the process ends but I wouldn't rely 100% on this.