# Friday, February 01, 2008

Great XNA Book Coming Soon

Rob Miles has finished his book on XNA development and it will be out in the wild soon. Although we don't have XNA support for mobile devices it is a cool framework which allows you to build games for both PC and XBox 360 with managed code. You can see a couple of sample chapters from the book which will help you get started with XNA Game Studio from Rob's site Very Silly Games which showcases some of the interesting things you can do with the framework. Not to mention the great puns in the Silly Ideas list.

#    Comments [0] |
# Wednesday, January 09, 2008

HttpWebRequest Exceptions under .NETCF

While testing code using HttpWebRequest it can be observed in the debug output that a number of exceptions are thrown within the GetResponse call of a HttpWebRequest. If you run exactly the same code on the desktop you don't see this behaviour. For reference the following is a simple example which displays the issue:-

System.Net.WebRequest request = System.Net.WebRequest.Create("http://www.microsoft.com");
System.Net.WebResponse webResponse = request.GetResponse();
webResponse.Close();

Since the exceptions are caught it doesn't stop the code from running but I considered it annoying enough to investigate and try to find the cause. Here is the typical output during the call to GetResponse:-

A first chance exception of type 'System.IO.IOException' occurred in mscorlib.dll
A first chance exception of type 'System.UriFormatException' occurred in System.dll
The thread 0x577c6eaa has exited with code 0 (0x0).
The thread 0xaf16af8a has exited with code 0 (0x0).
A first chance exception of type 'System.UriFormatException' occurred in System.dll
The thread 0x577c6eaa has exited with code 0 (0x0).
The thread 0xaf16af8a has exited with code 0 (0x0).
The thread 0xaf399a02 has exited with code 0 (0x0).

I eventually tracked it down to an issue with WebProxy. It occurs if you do not specify a Proxy or use the system proxy:-

request.Proxy = System.Net.GlobalProxySelection.Select;

If you won't be using a proxy you can set the Proxy property to an empty WebProxy:-

request.Proxy = System.Net.GlobalProxySelection.GetEmptyWebProxy();

After making this change you'll see the method progress without any exceptions - you'll just see the 5 thread exit notifications in the output. Whether or not this makes a noticeable difference to performance I have yet to discover but it does indicate an underlying issue since the desktop has no such problem.

#    Comments [5] |
# Wednesday, November 28, 2007

doPDF - Great PDF Printer

I needed to convert some files to PDF format today. While this is possible in Office 2007 products with a free add-in it isn't an option in other applications. I have an XPS printer and a OneNote writer but no way to produce a PDF. There are a number of solutions available and in the past I've had problems with ones which looked promising but that don't support Windows Vista. I stumbled across doPDF today and was very pleasantly surprised. It's freeware, supports Windows Vista and, like all software should, it just works. I rarely need to produce PDF files but now I know I have a solution I can rely upon.

#    Comments [0] |
# Friday, November 23, 2007

Determine Platform - .NETCF 3.5 and earlier

One of the new features in v3.5 of the Compact Framework is the ability to easily detect the platform you are running on from Smartphone (Standard Edition), PocketPC (Classic or Professional Editions) or WinCEGeneric (Everything else). The code is very straight-forward:-

using Microsoft.WindowsCE.Forms;

if(SystemSettings.Platform == WinCEPlatform.Smartphone)
{
   //do something smartphone specific...
}

 

In the latest (v3.0) version of Mobile In The Hand I've implemented a matching property, so for the above code sample you'd just change the using statement to use InTheHand.WindowsCE.Forms and the code would work the same way. This is available in both the .NETCF v1.0 and v2.0 builds of the library.

#    Comments [0] |
# Tuesday, November 13, 2007

WirelessManager sample

Mobile In The Hand 3.0 has just been released. This is the latest version of our .NET Compact Framework library for working with all aspects of Windows Mobile. This latest version is optimised for .NET Compact Framework 2.0 and 3.5 and introduces a number of new classes. One of these is the WirelessManager which allows you to toggle the radio mode of your Phone, WiFi and Bluetooth just like the built in Wireless Manager application. I have prepared this sample to demonstrate how to use the class. It exposes a single form with checkboxes for each of the radio types, toggling the checkbox changes the radio mode for the specific device. You will need to have Mobile In The Hand 3.0 installed to use this sample (The Evaluation Edition can be used). The sample can be downloaded here:-

http://inthehand.com/files/folders/resources/entry4227.aspx

#    Comments [0] |
# Monday, November 12, 2007

New RSS Feed Url

I've changed the site to publish the RSS feed through feedburner. Please update your news reader with the following URL to avoid any loss of service:-

http://feeds.feedburner.com/peterfoot/

Thanks!

#    Comments [0] |
# Wednesday, November 07, 2007

TechEd Session Content

I've begun uploading the content from the Networking session at Tech Ed. The rest of the example code will follow shortly. All the resources from the session can be found here:-

http://inthehand.com/files/folders/resources/entry4195.aspx

#    Comments [0] |
# Tuesday, October 16, 2007

Networking Session at Tech Ed Developers 2007

The schedule for Tech Ed is now set. Now, I can't compete with Daniel on quantity, but hopefully can equal him on quality. However this requires help from you - I am hosting an interactive session and so you can help steer the direction of the session (within the scope of networking and Windows Mobile of course). If you have any particular topics that you would like to see addressed then please let me know via the comments on this post, or via email (there is a contact link on this page). I'm going to bring with me a selection of code samples and some demos including some interactive Bluetooth content (so bring your Windows Mobile (or other Bluetooth equipped) devices along. Here are the details:-

Tue Nov 6 09:00 - 10:15 Room 131 MED01-IS An Open Discussion of Networking Technologies within Windows Mobile

I look forward to seeing you there!

#    Comments [2] |
# Tuesday, October 09, 2007

How To: Use the WebRequestMethods class

Networking In The Hand introduces a repository for all the various method types for FTP and HTTP operations. While the common ones are easy to remember ("GET","POST" etc) many others are not, and so this class (like its desktop equivalent) provides a central place to refer to them, without dotting your code with hard-coded strings. WebRequestMethods contains two static classes - Ftp and Http which as the name suggests contain the two sets of operations. Here we find one used in the previous sample:-

InTheHand.Net.WebRequestMethods.Ftp.GetDateTimestamp

As with all the functionality in the namespace, you'll find the full details in the online documentation library.

#    Comments [0] |
# Thursday, October 04, 2007

How To: Use the FtpWebRequest

Networking In The Hand includes a full desktop-compatible implementation of the FtpWebRequest class. This plugs into the WebRequest class so that calling WebRequest.Create() with an FTP Uri will create an object of type FtpWebRequest. Because FTP support isn't built into the Compact Framework you have to register the class with this prefix using the the following code (only required once in your code):-

InTheHand.Net.FtpWebRequest.RegisterPrefix();

We have already looked at performing simple operations with the WebClient class. for more complex FTP operations you can use the FtpWebRequest directly. For example retrieving the modification date of a specific file:-

FtpWebRequest requestDate = (FtpWebRequest)FtpWebRequest.Create(requestUri);
requestDate.Method = WebRequestMethods.Ftp.GetDateTimestamp;
if (wc.Credentials != null)
{
   requestDate.Credentials = wc.Credentials;
}
FtpWebResponse responseDate = null;

responseDate = (FtpWebResponse)requestDate.GetResponse();

if (responseDate != null)
{
   MessageBox.Show(responseDate.LastModified.ToString());
   responseDate.Close();
}

#    Comments [0] |
# Tuesday, October 02, 2007

How To: Use the WebClient

Networking In The Hand includes the WebClient class which is a helper class which makes it easier to do uploading and downloading of data using HTTP and FTP transports. For example rather than creating an HttpWebRequest, setting a number of properties, getting the response and reading the response stream and copying the data into a file, why not use DownloadFile to perform a single operation to write the data from a specific Uri to a local file:-

WebClient wc = new WebClient();
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
   wc.DownloadFile(uriTarget, saveFileDialog1.FileName);
}

Additional methods provide the ability to download a string, and download a byte array containing the data. There are a similar set of operations for uploading:-

if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
   wc.UploadFile(uriDestination, openFileDialog1.FileName);
}

Not only does this work with the HTTP transport, but also with the FTP support which is also part of the library - the only difference is the Uri that you pass in. If your site requires a username/password you can set the Credentials property of the WebClient once and they will be used for all subsequent operations.

#    Comments [0] |

Fix: SMS Interception on T-Mobile Dash

A number of customers have been reporting issues with SMS interception on the T-Mobile Dash handset. On these devices the SMS interception does not work through either the Microsoft or In The Hand class libraries. This is specific to the T-Mobile ROM as other branded versions of the same device, such as the HTC S620, do not have the problem. The culprit is a badly behaved IMessageFilter implementation which stops the standard interceptor from working. You can fix this issue by removing the entry from the registry. Take a look at this registry key:-

HKEY_LOCAL_MACHINE\Software\Microsoft/Software/Inbox/Svc/Sms/Rules

In here you'll find 2 entries by default on Windows Mobile 5.0:-

{1000BC1C-F4A3-4210-B197-4AEBF2CEE6F5}

{77990A0E-60B8-4103-B9AF-17157E4274FD}

If you find additional entries here try deleting them (make a backup first so that you can restore if necessary) then reset the phone. This should allow the normal SMS interception mechanism to work again.

On Windows Mobile 6 the above registry key is not present by default, therefore the standard SMS interception will work without any additional rules registered.

#    Comments [0] |
# Monday, October 01, 2007

How To: Use the Ping class

Networking In The Hand includes the Ping class (In the InTheHand.Net.NetworkInformation namespace). The component allows you to determine if a network path to a particular host is available and whether the host is responding. It doesn't guarantee that a particular service is running on the server (HTTP, FTP etc). You can perform a Ping in a couple of lines of code, the class has been designed to be an exact subset of the equivalent class in the full .NET framework. The following is an example of the simplest ping request using a default payload and timeout settings.

InTheHand.Net.NetworkInformation.Ping p = new InTheHand.Net.NetworkInformation.Ping();
InTheHand.Net.NetworkInformation.PingReply reply = p.Send("www.google.com");

if (reply.Status == IPStatus.Success)
{
   string message = string.Format("Address: {0}\r\nRoundTrip time: {1}\r\nTime to live: {2}\r\nDon't fragment: {3}\r\nBuffer size: {0}",
      reply.Address.ToString(),
      reply.RoundtripTime,
      reply.Options.Ttl,
      reply.Options.DontFragment,
      reply.Buffer.Length);

   MessageBox.Show(message, "Ping");
}
else
{
   MessageBox.Show(reply.Status.ToString(), "Ping");
}

The class allows you to further customise the request. You can specify your own data payload for example, or set a different timeout value (the default is 5 seconds).

#    Comments [0] |
# Friday, September 28, 2007

How To: Use the AuthenticationDialog

Networking In The Hand 2.0 offers a new dialog which allows you to prompt the user for networking credentials. The dialog is designed for the best appearance depending on your platform, for example the screenshots below show both Windows Mobile 5.0 Pocket PC and Windows Mobile 6 Standard Landscape:-

 

   

If your application stores authentication details you can pre-populate the dialog. Optionally you can display a Save Settings checkbox on the form. The following code snippet shows how to display the dialog and return the credentials as an ICredentials object:-

private ICredentials GetCredentials(string resourceName)
{
   InTheHand.Windows.Forms.AuthenticationDialog ad = new InTheHand.Windows.Forms.AuthenticationDialog();

   ad.ResourceName = resourceName;
   if(ad.ShowDialog() == DialogResult.OK)
   {
        return new NetworkCredential(ad.Username, ad.Password, ad.Domain);
   }
   else
   {
      return null;
   }

}

#    Comments [0] |
# Friday, September 21, 2007

New Networking Component

In The Hand Ltd today released Networking In The Hand, a developer library for the .NET Compact Framework 2.0 and 3.5 Beta. This library adds additional networking functionality not found in in the Compact Framework while matching the object model used in the full .NET framework to make it easy to share your code between platforms. Functionality includes:-

  • InTheHand.Net.WebClient - Provides helper methods for working with information upload and download over HTTP and FTP transports, and any other WebRequest based implementations.
  • InTheHand.Net.FtpWebRequest - Provides a complete desktop compatible implementation of the WebRequest pattern for FTP.
  • InTheHand.Net.WebRequestMethods - Provides a reference of all the HTTP and FTP methods (GET/POST etc)
  • InTheHand.Net.NetworkInformation.Ping - Perform a Ping and determine network availability and performance.
  • InTheHand.Net.NetworkInformation.IPGlobalProperties - Retrieve a wide range of networking statistics to measure traffic and help identify faults.

The library is licensed on a per-developer basis with no additional royalties required to distribute the runtime with your applications. Full details on the product can be found on the product details page - http://inthehand.com/content/Networking.aspx. A fully functionality Evaluation version is available to download - http://inthehand.com/files/folders/evals/entry4014.aspx.

#    Comments [0] |

Stephen Fry is Blogging

Stephen Fry, intellectual and comic hero has not only started blogging, but started talking about mobile devices. Definitely worth a read.

(from Dave Sussman)

#    Comments [0] |

Friday Fun: Untamed Workforce

There are videos and photos doing the rounds from a new spoof information site for Windows Mobile which takes a light-hearted look at mobile working. Why not take a look?

 

#    Comments [0] |