SqlConnection woes on the Compact Framework over WiFi

Last night at the Toronto .NET Users Group talk I did on mobility, a gentleman had a question about directly connecting to an Enterprise SqlServer database from a Pocket PC using the Compact Framework. His users run on a shop floor and some times they lose their wifi signal. While he doesn't keep the SqlConnection open the whole time, it seems that when a wifi signal is back alive his application can't connect to the database using a SqlConnection.Open anymore - despite that he can still ping the server.

He was correctly doing a SqlConnection.Close in a finally clause around his data access, but I suspect that even though pooling is not supported on the compact framework, this is not doing a proper disconnect of the physical connection (a Sql Profiler session would probably tell you that for sure). So a using block in C# will ensure that the SqlConnection is disposed of immediately and will properly terminate the connection. So if between calls you lose and reaquire your wifi connection you'll be starting a bran new connection the next time. It's still a good idea to put all of your actual work in a try/catch/finally block with a SqlConnection Close in the finally.

using (SqlConnection cn = newSqlConnection(CONNECTION_STRING ))
   //do some work with the connection
  catch (SqlException ex)
   //error handling

Get lost, have fun.

Ok this is too cool. Bell Mobility has this Location Service called MyFinder. Using Cellular triangulation they can figure out pretty close to where you are. It costs 25cents to locate yourself on any Bell Mobility Cell phone with a browser (plus air time ). You can do things like find the nearest gas station to where you are right now (or ATM, restaurant, etc.) and then using Map Point will give you driving/walking directions. I tried out this service in Waterloo and it found me within a block of where I actually was. Bell says within 150m. In my example that would be pretty close. So your mileage might vary (no pun intended).

If you are lucky enough to have Sanyo 8100 or an Audiovox 8450/8455 you can also use MapMe service which will download a map to your device and your location plotted on it - along with nearby places. This appears from the screenshot to be something along the lines of a Pocket Streets derivative. It costs $5 (one time) for the software, and again 25 cents to be located per use plus air time (unless you have the Mobile Browser Bundle).

Bell Mobility also has a few multiplayer games that you play against people nearby. Less cool. Get a life.

Perhaps the most (potentially) practical is a #TAXI phone number that connects you with the first available taxi based on your location. It uses many cab companies. It sounds like they might find you a taxi parked around the corner but I don't think it quite works that way. It found my city and routed me to the phone number of the nearest taxi company. It also sent me a text message with their direct phone number. A $1.25 a call? The taxi company should pay for that - no?


You can develop applications using this service too. If you are lucky to live in Canada and be a Bell Mobility Subscriber - then you are in luck (as I am) since Bell is now providing realtime MS MapPoint Location Service. It almost makes up for being on a CDMA network and having that limited phone selection problem.

Microsoft MapPoint Location Server is a new component of Microsoft MapPoint Web Service. You will install this component (along with SQL Server) in your enterprise and using the MapPoint Web Service and location data from your provider you can get an inventory of all the people in your company and their locations. For doing dispatch type of applications, 150 meters is probably close enough. General Information on both here (http://www.microsoft.com/mappoint)

MSDN Universal, Enterprise, and Professional subscribers are eligible for a free subscription to MapPoint Web Service (a requirement of using MLS)(https://s.microsoft.com/mappoint/msdn/msdnspec.aspx)

Bell Mobility Developers Web site for location based services (http://developer.bellmobility.ca/lbs/)



CTTDNUG UG Tomorrow Night: Building Pocket PC Applications with the Compact Framework and SQL CE

As part of the continuing MSDN User Group Tour, I'll be speaking at the Canadian Technology Triangle .NET User Group in Waterloo on Thursday October 7th (tomorrow night). There is a new location for the meeting at Agfa (formerly Mitra) in Waterloo. All the details are here.

Correction: Adam Gallant is going to be the speaker at this event tomorrow night. Sorry for the confusion. It should be a good talk.

Oshawa .NET: Building Mobile Applications

I'm doing a talk at the East of GTA .NET users group tonight in Oshawa. This is the same MSDN User Group tour event sweeping across Canada. I'll be talking about some of the limitations of the Compact Framework and SqlCE. Should be fun - hope to see you there.

Registration Links and slides (afterwards) can be found here.

VS.NET IDE Teaching an old Dog new Tricks

I love hanging out with new VS.NET developers. It's enlightening to hear the troubles the face and their new found energy to solve them. I have to blog more about these - but in general, there are often things that I do out of habit in the IDE or things that I live with because I'm too lazy (or tired or busy) to find a way around them.

Two new tricks were brought to my attention by an associate of mine.

“How do I find all of the references to a class or usages of a member?” or “When I right click on a class and select Go To Reference, it goes to the first one it finds. How do I go to the next one?”.

The best answer is CTRL+SHIFT+1 which will jump you to the next reference. CTRL+SHIFT+2 will take you to the next reference.

I couldn't find this short cut anywhere in the menu's. The complete list of short cuts can be found here.

Which begged another question. Can I put short cuts or favorites in the IDE? Indeed, under View>Other Windows there is a favorites window which is your machines favorites. This is great to have docked right next to your Dynamic Help (if you have it turned on).

A similar question was “How do I find all of the descendent's of a class or implementations of an interface?”. I always using the online help for that, which doesn't help for your own code. One of the solutions I found (and maybe there is a better one) is to use Find Symbol under the Find and Replace menu (ALT-F12).


GDI+ Security Vulnerability

There is a new critical security vulnerability that affects a wide range of software that can't be easily patched through Windows Update. The vulnerability lies inside of GDI+ and can allow a maliciously formed JPEG image file to create a buffer overrun and inject malicious code - even through a web page's graphics...no scripting or anything.

Windows Update will go ahead and update major components but you also need to go to the Office Update site as well as update a bunch of other software you might have on your machine.

In particular for developers, the .NET Framework (pre-latest service pack) and even Visual Studio.NET 2003 and 2002 are affected and need to be separately patched.

The full bulletin with links for all the various patches are available here. http://www.microsoft.com/technet/security/bulletin/MS04-028.mspx

If you go to Windows Update it will also provide you with a GDI+ Detection tool that will scan your hard drive looking for affected components. I strongly you recommend everybody jump all over this one quickly.

VS Live Orlando: Building "Operations-Friendly" ASP.NET Applications with Instrumentation and Logging

Yes, it's the longest title of all VS Live Orlando presentations! It's a big topic and it deserves a big name.

I'm heading out Monday night to hurricane country to deliver this talk on Tuesday morning. I like this topic because when you get into it, it's like an onion. It doesn't look like something terribly sophisticated but as you get into you find there are more and more layers to peel back.

Building Mobile Applications, Metro Toronto .NET Users Group

Tomorrow night I'm presenting at the downtown Toronto .NET users group - topic Pocket PC development with the CE framework. I'll have a new HP 4700 device with a VGA resolution screen for folks to take a look at - courtesy of your friendly neighborhood HP rep. I'll also have my trusty 5650 with the old form factor for you to play around with. Hope to see you there.

Details: http://www.objectsharp.com/oNewsUpdate/ReadingFullStory.aspx?StoryNum=-28

Shorthorn Longhorn

So this will cause a few blogs. I have just heard that....

  • Longhorn slated for 2006. Longhorn server 2007.
  • Winfx, and Avalon are coming to windows xp in 2006. Indigo as well - and on Windows 2003 as well. These are all part of WinFx that is going to be extremely important for .NET developers and companies wanting to take advantage of these improvements.
  • Winfs is leaving longhorn (post release). So that means ObjectSpaces and the Microsoft Business Framework too.

Wow. Never a dull moment. I'm attending a briefing with Jim Allchin in an hour so I might have more I can tell.

But will we also see a delay of ObjectSpaces or the Microsoft Business Framework until after the longhorn release. Those have been recently tied into WinFs - but no specific announcements about that - and I wouldn't be surprised if that changed soon. 

Is IntelliSense showing you everything?

Well I learned something new today. I can't believe I have been developing in Visual Studio .Net for so long without knowing this one. I'm sure someone showed me at one time or another. If they did I forgot.

A colleague of mine mentioned I should use a particular property on a particular class. When I went to use it, it did not show up in IntelliSense. I mentioned this to my very clever friend, who pointed out the following option to me. Apparently the property I was trying to access via IntelliSense was flagged by the developer as an advanced member.

If you have members in a class that you want to be treated as advanced, use the following attribute;