C# – How to display the “cannot connect” dialog in windows mobile when a webservice URL is unreachable

ccompact-frameworkmobilenetwindows-mobile

On windows mobile when there is no internet connection and I try to
browse the web using internet explorer i get cannot connect
information at the top of the screen. It says cannot connect with
current connection settings. To change your connection settings, tap
settings. And I am able to tap Settings and setup network connections.
How can I display cannot connect information programmatically? When I
cannot connect to a webservice using my application I would like to
show the same information and let the user set up network connections.
I use compact framework 2.0 and csharp.

Thanks in advance.

Best Answer

This is not the best answer, and I hope someone has a better one, but: one thing you can do when your app is not able to reach the webservice is to use the Process class (in System.Diagnostics) to start your webservice URL in Internet Explorer (aka "shelling out").

This will cause IE to appear, and since it can't see the webservice either, it will show the Settings dialog that you need. Once you change your settings so that you can see the webservice, you just close IE and now you're back in your app (which will now be able to see the webservice).