Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Application exits unexpectedly and without errors

Application exits unexpectedly and without errors

Scheduled Pinned Locked Moved C#
helpwinforms
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Ricardo Mendes
    wrote on last edited by
    #1

    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

    _ 1 Reply Last reply
    0
    • R Ricardo Mendes

      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

      _ Offline
      _ Offline
      _Bao_
      wrote on last edited by
      #2

      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.

      R 1 Reply Last reply
      0
      • _ _Bao_

        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.

        R Offline
        R Offline
        Ricardo Mendes
        wrote on last edited by
        #3

        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.

        _ 1 Reply Last reply
        0
        • R Ricardo Mendes

          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.

          _ Offline
          _ Offline
          _Bao_
          wrote on last edited by
          #4

          i can't really see where your code's wrong, maybe if you post more code or a link to it, more people could be able to help you.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups