Over the last few days I have been working on an online high score for the Windows Phone 7 game ‘plan bee’, which is done in XNA. (I guess this problem is also relevant for Silverlight applications). I had the service setup and all were good, data were flowing back and forth. To give the player a good experience when playing the game I of course started to test the game without internet connection, as this can happen on a mobile device like WP7
Then the game crashed right away and at first I just thought I forget to check for something and attached the debugger. The debugger showed me that an EndpointNotFound exception were thrown. I tried a lot of things and couldn’t figure out how I could avoid or catch this exception!
I tried to put try/catch around the freaking method calling the service, but the exception still insisted on begin thrown right when I tried to access the service. WTF!
Then I started googling around the net to see if anyone else had the same problem – and apparently I were not along with this – lucky me. People were tried really creative things, that were…yeah creative… but also really stupid some of them and wouldn’t work in the long run.
Suddenly I came across this little thread: http://forums.create.msdn.com/forums/p/69485/435804.aspx#435804
babaandthepigman: “Isn’t this exception a ‘first-chance exception’ caught by the debugger?”
In my aggressive attempt to figure out why this exception were thrown, I never tried it without the debugger and never had the time to press F5 after I saw the exception in the debugger. If I had done that, I would have discovered that the game continued to run and that I went into my “_Completed” event handler method where I could have checked for e.Error != null and have done what I wanted – without the game crashing.
The funny thing is that apparently is that a lot of people have done this – you might be one of them as you are reading this post Even funnier is how the thread just stops after the quoted comment above.
Hope this helped you with this “problem”.