Skip to main content

Glenn Wiley's Blog

Go Search
Home
About Me
  

Glenn Wiley's Blog > Categories
.Net Compact Framework - the red-headed step-child

I'm convinced the .Net Compact Framework is the red-headed step child of MS.  Every time I work with it I encounter some sort of mysterious voodoo going on.  My Visual Studio environment (VS2008 SP1) has already crashed on me twice in the past hour with my favorite mysterious error message, telling me that it encountered an exception and has to close now, so sorry.  My all-time favorite bit of magic involves some code like this:

if (someControl.Visible)
{
     ....do something
     someControl.Visible = false;
}

This is a contrived example of something in real code...check if a control is visible, if so, do something and then set the visible property to false.  Nothing too complicated here.  Amazingly, when you step through the debugger, passing the statement that sets the control's visible property to false, you can check the visible property and it is still true.  WTF?  Hover over someControl.Visible, or type it into the immediate window, or do a quick watch on it - same result, and it's reproducible.  This kind of nonsense drives me crazy and it's only one of many such things I've encountered with .Net CF development.  And I'm using v3.5...man, I really feel for anyone who had to work with this in earlier versions.  I really hope v4.0 is better.  I probably don't have to tell anyone who's worked with this before about how painful the debugging process is.  Hit F5, get some coffee, come back and wait while it finishes deploying, get another cup of coffee, and maybe this time it's ready to step through.  Ugh.  Okay, rant complete.

Connecting that device to the Internet

Oy!  I've been working to get a Visual Studio solution that I primarily work with on my work PC at home work, to also work on my new laptop.  The last piece of the puzzle, as it was with my desktop PC, was getting the Internet connection set up on the device so it would use the connection from the machine it is plugged into via USB.  Yet again, I forgot the basics and pulled out a few hairs until I remembered to set up my device connection settings in ActiveSync.

WindowsMobileConnectionSettings

Had to change that last dropdown to "The Internet" to get it all working.  You'd think after doing it a few times that it would be engrained into memory.  Sigh.  Now I'm back in business, able to hit the test web service on my laptop from the device, as well as external addresses.

Getting An Internet Connection To Work On A Mobile Device

I'm currently working on a mobile device application which will be used on the Symbol MC70.  Before I got one of these devices to work with, I had been using an old Dell Axim X5.  I had no issues before with internet connectivity when I was working with the Axim.  When debugging in Visual Studio, I deployed to the device and happily stepped through my code without any issues, connecting to a web service on my PC to retrieve data from a database.  I tried doing the same thing with the Symbol device and ran into an issue when I was trying to confirm that I could hit a web service on my development PC.  I found out that the Symbol device didn't have internet connectivity through the ActiveSync connection.  I opened IE on the device and typed in the URL to the web service on my PC without any luck.  I plugged the Axim back in just to be sure it still worked, and confirmed that it did.  Hmmm, so I thought maybe there was a different setting somewhere in my Connections settings.  Now, the Axim is using an older version of Pocket PC, so the settings aren't entirely the same because the Symbol device is using Windows Mobile 5.0, but the two devices were configured pretty much the same.  After an hour of piddling around with changing various settings, rebooting the device, reconnecting, etc, I tried one more thing.  I went to the Connections tab in the device Settings:

DeviceConnections 

I then entered the USB to PC settings:

USB_to_PC

<disclaimer>I don't know why this worked for me, but it did</disclaimer>

So, I uncheck the checkbox to see what happens.  I lost the connection to the device and tried reconnecting, which didn't work.  Not entirely unexpected.  In the meantime, I noticed a toast popup on my PC when I tried reconnecting to the device with this checkbox unchecked...the little toast you see when a device driver is being installed after plugging in a USB device.  After that, I went to the device and re-checked the checkbox.  Using Pocket Controller Pro (which is a very nice product to have if you do mobile development), I was able to connect to the device again.  Everytime I tried something new or changed a setting, I would go back into IE on the device to see if I could connect to my web service.  Lo and behold, this time it worked!  Now I have no clue what changed here, but somehow, unchecking the Enable advanced network functionality checkbox and re-checking it did something that solved my problem.  Amazing how sometimes you can totally punt when trying to figure something out and things just work.  It's a little unsettling that I don't know why, but my issue is no longer an issue.  I'm happily running my application on the device now, with no problems retrieving data from the web service.