views:

2321

answers:

5

Hi,

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?

+4  A: 

Look at Thread usage and async calls.

leppie
That was the problem... I overlooked an async call to a webservice connection... thanks.
scoob
+2  A: 

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?

Jon Skeet
+1  A: 

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

JaredPar
+1  A: 

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

SpaceghostAli
+2  A: 

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?

Scott Langham