Application exits unexpectedly and without errors
-
Hi. I'm trying to solve a very strange problem. I have a windows forms application that makes calls to a web service. When the web service method is invoked, it is executed without exceptions on the web service side. When this method returns, the application exits without exceptions. It simply closes with error 0 (success). Other methods of the webservice are called before this problematic method without problems. Another strange behaviour: if I am debugging the application, it ends on the initialization when I call the problematic webservice method. But if I run the executable itself (without debugging), the application starts (the problematic method works) but it fails on another webservice method invoked on a button click. The windows forms application looks like this: public void Main() { try { webService.NormalMethod1(); webService.NormalMethod2(); webService.ProblematicMethod1(); //returns a DataSet with one table and one row } catch(Exception ex) { MessageBox.Show(ex.ToString()); } } private void button_Click(object sender, EventArgs e) { try { webService.NormalMethod3(); webService.ProblematicMethod2(); //returns a string } catch(Exception ex) { MessageBox.Show(ex.ToString()); } } As I said, if I am debugging, after the webService.ProblematicMethod1() method is called the application ends. If I run the executable itself webService.ProblematicMethod1() works and when the button is clicked, webService.ProblematicMethod2() makes the application terminate. In both cases, the catch block is never reached (the MessageBox is never shown). I've created a event handler for the Application.ThreadException event but it is never invoked. The windows application also communicates with mobile devices through ActiveSync. The described problem only occurs when devices running Windows Mobile 5.0 are connected. It works fine with older devices. In my point of view, the PDA should not affect the windows application since what's involved in this piece of code is only the web service. I don't know what to do and I need to solve this problem as soon as possible. Any suggestions will be greatly appreciated. Thanks
-
Hi. I'm trying to solve a very strange problem. I have a windows forms application that makes calls to a web service. When the web service method is invoked, it is executed without exceptions on the web service side. When this method returns, the application exits without exceptions. It simply closes with error 0 (success). Other methods of the webservice are called before this problematic method without problems. Another strange behaviour: if I am debugging the application, it ends on the initialization when I call the problematic webservice method. But if I run the executable itself (without debugging), the application starts (the problematic method works) but it fails on another webservice method invoked on a button click. The windows forms application looks like this: public void Main() { try { webService.NormalMethod1(); webService.NormalMethod2(); webService.ProblematicMethod1(); //returns a DataSet with one table and one row } catch(Exception ex) { MessageBox.Show(ex.ToString()); } } private void button_Click(object sender, EventArgs e) { try { webService.NormalMethod3(); webService.ProblematicMethod2(); //returns a string } catch(Exception ex) { MessageBox.Show(ex.ToString()); } } As I said, if I am debugging, after the webService.ProblematicMethod1() method is called the application ends. If I run the executable itself webService.ProblematicMethod1() works and when the button is clicked, webService.ProblematicMethod2() makes the application terminate. In both cases, the catch block is never reached (the MessageBox is never shown). I've created a event handler for the Application.ThreadException event but it is never invoked. The windows application also communicates with mobile devices through ActiveSync. The described problem only occurs when devices running Windows Mobile 5.0 are connected. It works fine with older devices. In my point of view, the PDA should not affect the windows application since what's involved in this piece of code is only the web service. I don't know what to do and I need to solve this problem as soon as possible. Any suggestions will be greatly appreciated. Thanks
-
It's a normal behaviour, if you put code in your Main() like any other function, it will return after the last instruction, in your case: webService.ProblematicMethod1(); So, if there's nothing else to execute after, the program will terminate.
I've tried to simplify the code and made a obvious error. The code in Main method is in reality inside the Form.Load event. After the method calls the form should be displayed, but the application terminates. Sorry for the confusion.
-
I've tried to simplify the code and made a obvious error. The code in Main method is in reality inside the Form.Load event. After the method calls the form should be displayed, but the application terminates. Sorry for the confusion.