About UsCommunityTrainingContent DevelopmentContact

Blogs
Pluralsight
Course Schedule
Scott Allen
Craig Andera
Mark Baciak
Don Box
Keith Brown
John CJ
Tim Ewald
Jon Fancey
Jon Flanders
Vijay Gajjala
Kirill Gavrylyuk
Ian Griffiths
Martin Gudgin
Jim Johnson
John Justice
Mike Henderson
Joe Hummel
Matt Milner
Ted Neward
Fritz Onion
Brian Randell
Jeffrey Schlimmer
Aaron Skonnard
Dan Sullivan
Herb Sutter
Doug Walter
Jim Wilson
Mike Woodring

My Links
Home
Contact
Login

Blog Stats
Posts - 221
Stories - 0
Comments - 527
Trackbacks - 69

Archives
May, 2008 (1)
Apr, 2008 (4)
Mar, 2008 (6)
Feb, 2008 (8)
Jan, 2008 (3)
Dec, 2007 (5)
Nov, 2007 (5)
Oct, 2007 (8)
Sep, 2007 (13)
Aug, 2007 (6)
Jul, 2007 (6)
Jun, 2007 (5)
May, 2007 (8)
Apr, 2007 (8)
Mar, 2007 (7)
Feb, 2007 (11)
Jan, 2007 (9)
Dec, 2006 (3)
Nov, 2006 (4)
Oct, 2006 (10)
Sep, 2006 (9)
Aug, 2006 (6)
Jul, 2006 (3)
Jun, 2006 (5)
May, 2006 (1)
Apr, 2006 (14)
Mar, 2006 (7)
Feb, 2006 (9)
Jan, 2006 (10)
Dec, 2005 (3)
Nov, 2005 (13)
Oct, 2005 (8)
May, 2005 (2)
Feb, 2005 (1)


Mobile device and smart client development thru the eyes of Jim

Sunday, May 11, 2008

Due to a last minute scheduling problem, my planned appearance on geekSpeak last week to talk about Windows Communications Foundation (WCF) Strategies for Windows Mobile had to be rescheduled.

I realize it's a bit of short notice but I wanted to let everyone know that it is now scheduled for Monday 12-May at 12-noon PDT (3PM EDT, 19:00 UTC). The URL to register for the webcast is still the same.

I really encourage you to come by and checkout this webcast. Although, our initial point of reference is WCF on Windows Mobile, most of what we talk about applies equally to all mobile-oriented applications whether running on a Windows Mobile device, or laptop/notebook computer.

One of the key areas we'll address is the Store and Forward transport and its usefulness in applications that may be intermittently online or that may switch between wired, wireless, or cellular networks.

Remember that geekSpeak webcasts are more interactive than most, allowing an opportunity for you to ask questions and for us to share a very interactive dialog. As always though, I'll be showing some demos so that you can see some real code at work.

I hope to see you there. If you're not yet doing mobile application development, you almost definitely will be doing so very soon and this is a great way to learn about some of the common considerations and solutions for communicating in this loosely-connected environment.

posted @ 9:27 AM | Feedback (2)

Monday, April 28, 2008

It looks like Webcast season is upon us J

Between now and Tech Ed, Maarten Struys and I will be presenting a combined total of 7 webcasts.

This Wednesday, 30-April and next Wednesday, 7-May I'll be the guest on MSDN's geekSpeak.

Then starting next week (week of 5-May), Maarten Struys and I will be co-presenting a multi-part webcast series on a variety of Windows Mobile topics as a lead-in to Tech Ed Developer 2008.

geekSpeak

This Wednesday (30-April) I'll be talking about SQL Server Compact Tips and Tricks (both devices and desktop).

I'm really looking forward to this talk. Those of you who have followed my blog or who have seen my whitepapers or webcasts know that I'm a big fan of SQL Server Compact. Although it provides excellent code & SQL compatibility with SQL Server, the details of the underlying architecture sometimes require a different approach. That's what we'll be talking about … how to get the most out of SQL Server Compact.

Next Wednesday (7-May), I'll be talking about Windows Communication Foundation (WCF) Strategies for Windows Mobile.

Although not the focus of the entire webcast, we'll definitely be talking a bunch about using Store-and-Forward messaging. Whether you're targeting Windows Mobile devices or focus more on desktop applications, you'll want to be there.

Most of the same strategies we use for Windows Mobile applications apply equally to applications running on a laptop/notebook computer with Store-and-Forward messaging being a great example. Any application (Windows Mobile or Laptop-based) that needs to be away from connectivity periodically faces communications challenges that Store-and-Forward messaging addresses as it allows your app to simply send messages and the Store-and-Forward mechanism caches the messages automatically sending them whenever connectivity becomes available.

Bring your questions: If you haven't been to a geekSpeak webcast before, you don't know what you're missing.

These are much more two-way than traditional webcasts. Don't get me wrong, I love traditional webcasts where I get to show you a bunch of code but geekSpeak provides a great adjunct. On geekSpeak we engage much more in a conversation; the discussions are very listener driven with much of the time focused on addressing those things that you ask about.

Countdown to Tech Ed Developer 2008

We don't have all of the details posted yet but staring next week (week of 5-May), Maarten and I will be doing webcasts each week covering a different aspect of Windows Mobile development.

The webcasts are aimed at people who are new to Windows Mobile or who may be looking to gain a deeper understanding of the tools and capabilities of Windows Mobile application development. Keep a watch here on my blog and I'll provide further details on these webcasts as we get them published.

 

posted @ 6:23 PM | Feedback (0)

Friday, April 18, 2008

You may recall my webcast from about 6/7 weeks ago where I talked about how to use custom extension methods to allow your mobile device applications to efficiently query a SQL Server Compact (SSC) databases directly.

I received a question today regarding the webcast. The question relates to the verbosity of returning anonymous types when using the technique discussed in the webcast. For example…

var records = from order in resultSet
where (string)order["Ship Country"] == "UK"
select new
{
ShipName = (string)order["Ship Name"],
ShipAddress = (string)order["Ship Address"],
ShipCity = (string)order["Ship City"],
ShipPostalCode = (string)order["Ship Postal Code"],
ShipCountry = (string)order["Ship Country"],
ShipVia = (int)order["Ship Via"]
};

The verbosity is necessary because "order" in the above LINQ statement is of type SqlCeUpdatableRecord. Although Visual Studio supports generating typed-wrappers for SqlCeResultSet, it doesn't generate wrappers for the SqlCeUpdatableRecord corresponding to the SqlCeResultSet. With that being the case, specifying the individual column values within the anonymous type declaration requires you to use either the indexer (or Getxxx functions).

Ultimately there's nothing we can do about the way the column values are accessed (unless you write your own typed-wrapper generator for SqlCeUpdatableRecord). What we can do is move the code that creates the anonymous type into a separate function.

private object ShippingColumns(SqlCeUpdatableRecord order)
{
return new
{
ShipName = (string)order["Ship Name"],
ShipAddress = (string)order["Ship Address"],
ShipCity = (string)order["Ship City"],
ShipPostalCode = (string)order["Ship Postal Code"],
ShipCountry = (string)order["Ship Country"],
ShipVia = (int)order["Ship Via"]
};
}

With that, the LINQ statement becomes very simple.

var records = from order in resultSet
where (string)order["Ship Country"] == "UK"
select ShippingColumns(order);

Once we move the anonymous type declaration to a separate function we can take things one step further and optimize the column access by caching the column ordinals and then retrieving the column values using the Getxxx functions.

private object ShippingColumns(SqlCeUpdatableRecord order)
{
if (_nameIndex == -1)
InitializeIndexes(order);

return new
{
ShipName = order.GetString(_nameIndex),
ShipAddress = order.GetString(_addressIndex),
ShipCity = order.GetString(_cityIndex),
ShipPostalCode = order.GetString(_postalCodeIndex),
ShipCountry = order.GetString(_countryIndex),
ShipVia = order.GetInt32(_viaIndex)
};
}

private
void InitializeIndexes(SqlCeUpdatableRecord record)
{
_nameIndex = record.GetOrdinal("Ship Name");
_addressIndex = record.GetOrdinal("Ship Address");
_cityIndex = record.GetOrdinal("Ship City");
_postalCodeIndex = record.GetOrdinal("Ship Postal Code");
_countryIndex = record.GetOrdinal("Ship Country");
_viaIndex = record.GetOrdinal("Ship Via");
}

private
int _nameIndex = -1;
private int _addressIndex = -1;
private int _cityIndex = -1;
private int _postalCodeIndex = -1;
private int _countryIndex = -1;
private int _viaIndex = -1;

Although not a huge performance increase, storing the column indices does eliminate the overhead of the indexer looking up the column name each time. More importantly, using the strongly-typed Getxxx functions eliminates the overhead of boxing any column values that are value-types. As you know, excessive boxing creates a lot of scrap objects which leads to increased memory and garbage collection overhead.

Using regular class methods like those above work just fine; however, if you find that you use a common anonymous type throughout different parts of your application, you may want to use an extension method – extension methods are also nice just because of their class-member-like syntax.

public static class ResultSetExtension
{
public static IEnumerable<SqlCeUpdatableRecord> Where(
this SqlCeResultSet resultSet, Func<SqlCeUpdatableRecord, bool> theFunc)
{
return new PrepAwareEnumerableWrapper(resultSet, theFunc);
}

public static object ShippingColumns(this SqlCeUpdatableRecord order)
{
if (_nameIndex == -1)
InitializeIndexes(order);

return new
{
ShipName = order.GetString(_nameIndex),
ShipAddress = order.GetString(_addressIndex),
ShipCity = order.GetString(_cityIndex),
ShipPostalCode = order.GetString(_postalCodeIndex),
ShipCountry = order.GetString(_countryIndex),
ShipVia = order.GetInt32(_viaIndex)
};
}

private void InitializeIndexes(SqlCeUpdatableRecord record) { ... }

With the extension method, the LINQ statement becomes…

var records = from order in resultSet
where (string)order["Ship Country"] == "UK"
select order.ShippingColumns();

A couple of notes before I finish up…

One thing to keep in mind is that all of these functions that create the anonymous type have a return type of object. This means that the IEnumerable<T> collection that is created by the LINQ statement will be of type IEnumerable<object> rather than IEnumerable<compiler_generated_type>. In most cases this difference does not matter but it is something to be aware of.

And for a final note, if you do find yourself returning the same anonymous type construct from a number of LINQ statements, you might want to consider defining an explicit type and then constructing instances of that type within the LINQ statement. In my experience, anytime I find myself using an anonymous type/function/etc. more than once or twice that I ultimately end up needing access to it in my code in a non-anonymous fashion.

To return a specific type from a LINQ statement, simply define a type that has a constructor that accepts a SqlCeUpdatableRecord and assigns the desired columns to the corresponding type members – basically the constructor will look like the ShippingColumns methods shown above. Assuming that you've defined a class named ShipInfo with the appropriate constructor, your LINQ statement would look like the following…

var records = from order in resultSet
where (string)order["Ship Country"] == "UK"
select new ShipInfo(order);

I've updated one of the samples from the original webcast to include examples of what we've talked about in this post. If you'd like the updated sample, you can download it from here. The methods you'll want to look at in the download are menuRedefineType_Click, menuDynamicType_Click, menuDynamicTypeExtMethod_Click all of which are in the Form1.cs source file.

posted @ 2:37 PM | Feedback (5)

Wednesday, April 09, 2008

I came across this article: New anti-terror weapon: Hand-held lie detector on MSNBC today.

The article talks about a new hand-held lie detector that the Pentagon is issuing to soldiers in Afghanistan to help in screening local-police, interpreters, etc.

I couldn't find Microsoft or Windows Mobile mentioned anywhere in the article but take a look at this picture of the application screen …

The tell-tale Start icon appears in the top-left corner, and the familiar network activity and sound icons followed by the time appear in the top-right corner.

Something that I found funny … For an overview of the tool, the Pentagon has made a PowerPoint presentation available. J

All joking aside, it's really cool to see Windows Mobile being used in such a critical application

posted @ 10:34 AM | Feedback (5)

Tuesday, April 08, 2008

The other day while working in Visual Studio 2008, I encountered an unexpected error while attempting to create a DataGrid by dragging a table from the Data Sources pane onto a form (something we've all done many times).

At first Visual Studio appeared to be creating the DataGrid and associated components (BindingSource, TableAdapter, etc.) correctly but then Visual Studio threw an error:

An error occurred while performing the drop:

Length cannot be less than zero.
Parameter name: length

The error message might have been useful if I had access to the Visual Studio source code – but I was just using Visual Studio, not building it. Needless to say, the error message was of little help. J So I did what we all do in such situations, used trial-and-error.

The project calls a WCF service through a proxy generated by NetCfSvcUtil.exe; as an experiment, I decided to remove the WCF proxy from the project (and any calls to the proxy) to see what happened.

… VOILA …

Visual Studio was then able to create the DataGrid with no problem.

To verify what I had observed, I added the WCF proxy (and any associated calls) back into the project and deleted the DataGrid. Just as before, when I tried to create the DataGrid, Visual Studio threw the same error – so now I know where to start looking for the problem.

When I checked out the source file for the WCF proxy I realized that there was no namespace declaration. As you may know, if you run the NetCFSvcUtil without specifying the "/namespace" option then the types are not placed within a namespace….

So as an attempt at a solution, I created the WCF proxy so that the contained types were in a namespace (and added the appropriate using statement to the form class) – I then deleted the DataGrid from the form. Now when I dragged the table from the DataSource pane to the form, the DataGrid was created without any trouble - putting the types in a namespace completely resolved the problem. The program also compiles and runs as expected.

Now things are working – My assumption at this point was that there must have been a type name conflict (or something similar) between the WCF proxy types and the DataGrid-related types; seemed a reasonable assumption.

… BUT… here's the thing …

To confirm my assumption about the name conflict, I created the WCF proxy so that the contained types were not in a namespace (and of course removed the associated using statements) but left the generated DataGrid place. If there were a type name conflict between the DataGrid-related types and the WCF proxy the compiler should report the error

… BUT … get this …

The code compiles and runs perfectly --- the namespace was required for Visual Studio to create the DataGrid (and/or associated components) but the namespace is not required for the code to compile and run -- what?!?!

So what does this all mean? … At this point my guess is that Visual Studio and the DataGrid creation process have a type name sensitivity that may not be consistent with the .NET CF language requirements. If that is the case it would appear to indicate a possible bug but can't be 100% certain until the problem is narrowed down specifically.

I haven't had a chance to narrow down things further quite yet but I hopefully will shortly. As soon as I have the answer I'll post it here.

One thing to keep in mind, if you do run into the error I describe above, look for any possible name conflicts or classes outside of a namespace. It seems that there's a good chance that that's the source of the problem.

I hope to have more to report soon.

posted @ 10:32 AM | Feedback (0)

Thursday, March 27, 2008

A short divergence from my regular technical posts...

If you have a cat, you can't help but laugh due to the insane accuracy of these videos

Simon's Cat in Cat Man Do

Simon's Cat in Let Me In

Videos are originally from “And then there were four

For other fun cat content checkout Buzzerbee's blog  and the many other sites it links to.

posted @ 1:43 PM | Feedback (1)

Friday, March 21, 2008

A couple of weeks ago there were indications that Adobe's hope for continued adoption of Flash-Lite on mobile devices was possibly in jeopardy.

First there was the Microsoft MIX08 announcement of Silverlight for Mobile which, of course, competes with Flash-Lite; then Steve Jobs said that Flash-Lite didn't offer the power that iPhone requires.

Oh but how quickly things change…

It certainly is an exciting time to be a mobile device developer. J

posted @ 7:38 AM | Feedback (0)

Tuesday, March 18, 2008

If you do much work with Windows Mobile applications, there's a good chance that you frequently use the Cellular Emulator to test out things like call handling, SMS message handling, as well as cellular network behavior. I'm a pretty big fan of the Cellular Emulator … I remember what it was not that long ago when we didn't have it … that said …

There is one thing that I do sometimes find bothersome (yes I know this is a very small thing) – it's the process of associating the Cellular Emulator with a Device Emulator. You have to:

  • Open the Device Emulator Configuration dialog
  • Select the Peripherals tab
  • Enter the Cellular Emulator COMx port number into the Serial Port 0 field
  • Dismiss the Configuration Dialog
  • Reset the Device Emulator by selecting File | Reset | Soft
  • Click OK to confirm the soft reset

I realize that there are bigger problems in the world but when you test your apps across several different Device Emulators multiple times each day, that little 6-step process gets old. Fortunately, thanks to the Device Emulator Manager API one can create a little program to automate the whole process.

In an attempt to be a better person and to help my fellow man J … I thought I should share this little, but very helpful block of code.

public static void AssociateDeviceAndCellularEmulator(string emulatorName, string commPort)
{
IDeviceEmulatorManager emulatorManager = new DeviceEmulatorManagerClass();
IDeviceEmulatorManagerVMID theEmulator = FindEmulator(emulatorManager, emulatorName);

// Start the device emulator if not already running
if (theEmulator.get_State() == EMULATOR_STATE.EMU_NOT_RUNNING)
theEmulator.Connect();

SetEmulatorCommPort(theEmulator, commPort);

// Soft-Reset the Device Emulator
theEmulator.Reset(1);
}

 

private static void SetEmulatorCommPort(IDeviceEmulatorManagerVMID theEmulator, string commPort)
{
string originalConfigString = theEmulator.GetConfiguration();
XmlDocument configXml = new XmlDocument();
configXml.LoadXml(originalConfigString);
XmlNamespaceManager nsManager = new XmlNamespaceManager(configXml.NameTable);
nsManager.AddNamespace("decfg", "http://schemas.microsoft.com/DeviceEmulator/2006/01/DeCfg");

XmlElement serialPort0 = (XmlElement) configXml.SelectSingleNode(
"/decfg:DeviceEmulator/decfg:Peripherals/decfg:SerialPort[@UARTNumber='0']",
nsManager);
serialPort0.InnerText = commPort;

string updatedConfigString = configXml.OuterXml;
theEmulator.SetConfiguration(updatedConfigString);

}

 

The first function takes care of starting the Device Emulator if it isn't running and doing the soft-reset of the Device Emulator. Before doing the reset, it first calls the 2nd function, SetEmulatorCommPort, which retrieves the specified Device Emulator's current configuration XML, locates the serial port 0 element, assigns the correct COMx port number, then passes the updated configuration XML back to the Device Emulator. After which, the Device Emulator is correctly associated with the Cellular Emulator and is ready to use.

With these functions in place, to associate the Windows Mobile 6 Professional Emulator with the Cellular Emulator (we'll assume it requires COM4) – we just make the following function call.

AssociateDeviceAndCellularEmulator("Windows Mobile 6 Professional Emulator", "COM4");

Just a little bit of code but I find it makes my day-to-day application testing a little easier.

 

posted @ 1:19 PM | Feedback (0)

Tuesday, March 11, 2008

According to a report in techradar.com today

"Microsoft has confirmed to TechRadar that it will look to build a version of Silverlight that will work on the iPhone"

I haven't seen such a commitment corroborated by any other source yet but techradar.com makes it sound pretty good.

I am a little concerned by the phrase "will look to build" – as that doesn't quite sound like a commitment on Microsoft's part – but, fingers-crossed; I hope that it's true.

posted @ 1:34 PM | Feedback (2)
 

Like many, I really like the ongoing trend of providing developer-related information in the form of videos.

I suppose I'd better … although I don't know the exact count, the number of "How Do I Videos for Devices" and On-Demand Webcasts I've made total in excess of 100 – BUT, I'm a bit bothered by what appears to be a trend of delivering developer-related content in only video form.

I recently needed to ramp up quickly on a particular technology and I did what I always do in such a circumstance; I tried to locate a few pieces of good content that would give me a solid foundation in the technology so I could then start writing programs to experiment with the technology's ins-and-outs.

My search for content didn't quite go as I hoped. My problem was not that I couldn't find any content on the subject; I found quite a lot of content. The problem was that virtually all of that content was videos. There were a few papers available but they tended to focus on high-level topics and generalities; not really much I could use to start actually working with the technology.

In my personal experience, I find videos useful for getting information on how to perform a particular task but I find them to be of limited value when trying to build up an overall picture of the technology. I also find that in some cases videos slow down the learning process. In the case of using papers, one can read just particular sections of interest, quickly skip past topics not of interest, and easily refer back and forth between multiple papers; all things not easily done with videos.

So all of you content producers, content managers, and decision makers out there … please keep written-content coming.

Written content and videos are fantastic compliments to one another … they're not replacements.

 

 

posted @ 12:00 PM | Feedback (2)


 
   
 
© 2004 Pluralsight.
Visual Design by Studio Creativa
Privacy Policy