Question

I have an .net C# console application (not a service). it basically connects to a webservice, gets some xml files, copies those files to a few location on a drives, validates the xml, processes it and sends these objects to another web service.

However, when the main method exists (and the console window closes) I can still see the process in task manager.

I tried surrounding everything in the main method with a try, to catch an ApplicationException, and I still got nothing as to why the app crashes even though everything works smoothly otherwise...

Anybody has a clue as to where to begin to check for the faulty part?

Was it helpful?

Solution

Look at Thread usage and async calls.

OTHER TIPS

If the console window has closed, it seems very odd indeed that the process is still running. Can you attach to it in the Visual Studio debugger? (Obviously a debug build.)

Are you sure it's not a previous run which is still executing?

If you're debugging the app, then I've seen the situation where Visual Studio creates a host exe named similar to your app with .vshost.exe at the end. It uses that control your app for a better debugging experience. This host exe stays around after you've finished debugging your program so that its waiting and ready so it can start a new debug session quickly.

Are you sure it's not this exe that's hanging around?

If you run your application without debugging, does it still hang around then?

You almost certainly have an un-terminated thread in your application. As Jon said, attach with the debugger and see what threads are alive.

As all the other answers have suggested you probably do have a lingering thread but its not necessarily one that you created explicitly, you may need to call Dispose or something similar on one or more of your objects

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top