Nick's .NET Travels

Continually looking for the yellow brick road so I can catch me a wizard....

Why having a Database Engine in ROM is a good idea

Yesterday I came across an interesting site dedicated to Mobile Synchronisation and noticed they had a post regarding Symbian and the fact that in the next version of their OS (v9.5) they will follow Microsoft's path of including a database engine (SQLLite fo Symbian, SQL Server CE for Windows Mobile) in ROM.

The author attempts to make the point that he doesn't understand why you would want to include a database engine in ROM, or a runtime such as .NET CF for that matter. They point out that you "still need to install your mobile application so what is the big deal of reducing your install size by a few 100KB?".  IMHO there are a couple of compelling reasons to include both the runtime and database engine in ROM:

  • Firstly it means that you don't need to package it with your application - although the size saving isn't that great, it is just another thing that you have to include in your installer (better that someone else deals with this). 
  • It also means that the database engine is only deployed once (since SQL Server CE can be deployed as a set of dlls, in theory you could have multiple applications all with their own instance of the database engine).
  • I think the most significant reason for including the runtime and database engine in ROM is to make the OS more appealing to developers.  If I know that all WM6 devices are going to be able to run my application because it has the runtime and db engine included then I am likely to target that device for any new applications.  This is similar to the decision to include the .NET Framework v3 in Windows Vista (in contrast to previous versions of Windows where the .NET Framework is an optional install).

I was also intrigued by the author's comment regarding the inclusion of SQL Server Express in [VS2005] a marketing ploy.  Perhaps it was but developers still have the choice as to whether it gets installed (as with other components of VS) and it does mean that developers don't need to worry about downloading/purchasing a database engine in order to build database applications.

Get your WCF on the run

Mark Prentice of the .NET Compact Framework team has just posted an introduction on how you will be able to work with the WCF-over-email solution that will come out as part of v3.5 of the .NET CF.  At the MVP Summit we saw this in action and enough to say it is way cool.  Although I can't see Steve getting all enthusiastic about using Sync Services across this binding, I think there is a huge potential here for organisations to start leaveraging their investment in Outlook/Exchange by building peer-to-peer messaging based applications.


BIG NEWS for TFS users - Microsoft Acquires DevBiz

Anyone working with TFS will be over the moon to know (as per Brian Harry's post) that Microsoft has just acquired DevBiz.  This is a significant gap stop in a fundamentally v1 product where simple web accessibility was not readily available.  Team Plain was almost a no brainer, despite the additional per seat cost.  Now with the Microsoft acquisition you have no excuse.  Of course, don't forget the per seat CALs you need to access TFS!

Must have coffee....

I'm glad to hear from various sources that the weekly coffee gathering we started a month or so ago is still going strong in my absence.  I just want everyone to know that I'm back in town and keen to catch up with everyone. 

Don't forget:

    Every Tuesday, 1:30pm @ Tiger Tiger

Visual Studio Refresher: Tools -> Options (2)

This post continues the discussion around the Tool -> Options screen in [VS2005].

[Goto to root post]

Environment - Add-in/Macro Security

Allow macros to run: Toggles whether macros are able to be created, edited or executed.  Disabling this option will immediately disable all macro menu items in the IDE (both under the Macros item in the Tools menu and the Macro Explorer under the View->Other Windows menu item).  Note that if the Macro Explorer is already open it will remain visible, at least until you restart the IDE

Allow Add-in components to load: This option toggles whether Add-ins can load or not.  Unfortunately it really depends on how well the Add-in is written as to whether they are visible or not.  For example the AnkhSVN component still appears in the Tools menu on my machine, however clicking any of the items does nothing. Note that this option also disable the Add-in Manager item in the Tools menu.

Allow Add-in components to load from a URL: Well as you can guess this allows add-ins to be loaded from a url - well duh!  I guess this option is there if you really want to shoot yourself in the foot ;-)

Add-in File Paths: This is a series of locations from which add-ins will be loaded (assuming Add-in components is enabled).  By default there are a series of predefined locations:

%ALLUSERSPROFILE% - C:\Documents and Settings\All Users\Application Data\Microsoft\MSEnvShared\Addins

%APPDATA% - C:\Documents and Settings\<username>\Application Data\Microsoft\MSEnvShared\Addins

%USERPROFILE% - C:\Documents and Settings\<username>\My Documents\Visual Studio 2005\Addins

%VSAPPDATA% - C:\Documents and Settings\<username>\Addins

%VSCOMMONAPPDATA% - C:\Documents and Settings\All Users\Addins

You can of course add your own or remove these at will to control where add-ins are loaded.

OpenNETCF - Quiet but not stagnant

Anyone working in the .NET CF space will know that the team at OpenNETCF have been leading the way with their Smart Device Framework.  In v1 of the .NET CF the SDF was essential to have any reasonably functioning application.  Now with v2 the SDF is less essential, but you still quickly hit the limitations of the .NET CF. 

Recently Chris has posted about the new LargeIntervalTimer class that is coming in v2.1 of the SDF. A challenge faced by device developers is periodically waking the device up to say synchronise, poll for changes or do some other task.  When a device is in standby mode your managed code doesn't get an opportunity to execute so you can't rely on normal timers.  You actually need to hook the OS and to do that gracefully you really need the elegance of the SDF - check out the post for the code!

Personally I can't wait for them to release v2.1 so I can start working with the new additions.

VB9 Features

I've just noticed, care of Bill and Beth, that the VB9 features article has been updated as of February this year.  After a quick scan there are some clear changes that look great (and some that don't)!

Object Initializers

Dim c as New Country With { .Name = "Palau", .Area = 458, .Population = 16952 }

What I like about this notation is that it follows the VB tradition of using the With statement.  Previously you would have written:

Dim c as New Country()
With c
End With

The new notation is particular efficient if you want to initialise a collection of Country objects as each object can be instantiated and properties set in a single statement. For example:

Dim countries = { _
   New Country With { .Name = "Palau", .Area = 458, .Population = 16952 }, _
   New Country With { .Name = "Monaco", .Area = 1.9, .Population = 31719 }, _
   New Country With { .Name = "Belize", .Area = 22960, .Population = 219296 }, _
   New Country With { .Name = "Madagascar", .Area = 587040, .Population = 13670507} _

Implicity typing

In the last section you will have noticed that I didn't specify the type of the countries collection.  This is NOT because I haven't allowed VB.NET to run riot, it is because we have implicit typing.  This defines countries to be of type Country(). Why, because the right hand side defines an array of Country objects - we can see that, and now the compiler can too.

WARNING: To all those developers (including C# developers using the new var keyword) out there who are going to start using this feature throughout their code you are as bad as those VB6- developers who used Variant objects, or for that matter .NET developers who use object objects cause they can't be bothered getting it right.  The reason for this is that it makes your code harder to read and understand - you can't just read the variable declaration and know what type it is, instead you have to dissect the right hand side.  The ONLY time IMHO that implicit typing should (and in fact sometimes has to) be used is in a Linq statement.


Yeh, yeh, yeh - by now I'm hoping we have all heard, if not seen, Linq.  So just for clarrification we are talking about:

Dim smallCountries = From country In countries _
                                  Where country.Population < 1000000 _ 
                                  Select country

Of course it goes without saying that this is fundamentally cool! Before we go further though, it is worth noting that smallCountries is an IEnumerable(of Country) - if you aren't comfortable with Interfaces, now would be great time to begin using them!

Lambda Expressions


Function(Country As Country) country.Name
Function (Country As Country) country.Population < 1000000

These can be written as inline (like mini-anonymous methods) such as:

Dim smallCountries = _
   Enumerable.Select( _
      Enumerable.Where(countries, _
         Function (country As Country) country.Population < 1000000), _ 
      Function(country As Country) country.Name

IMHO this is probably one of the weakest of the new features available in VB9.  The VB.NET community has long been asking for both anonymous methods and interators.  Instead of giving us C#2.0 feature parity the team has leap frogged into Linq giving us only minimal lambda expressions.  Luckily this will only affect the hardcore developers out there who are building collections and doing fancy framework development (damn, looks like I might have to go back to C# afterall).

Nullable Types

Ok, so we have seen this before but this time we have the ? syntax, just like C#v2:

Partial Class Country
   Public Property Independence As Date?
End Class


There are a bunch of other features such as XML support and Relaxed delegates that didn't make this blog post.  I'd encourage you to read the full article and be prepared.  These features, especially IMHO Linq, are going to have more impact than Generics did!

Snippets and Stored Procedures

Mitch has posted a simple snippet that shows how you can work with stored procedures in C#.  I figured that I'd firstly translate this to VB.NET: 

' Execute a stored proc to read data
Using conn As New SqlConnection(connectionString), _
          cmd As SqlCommand = conn.CreateCommand()

   cmd.CommandText = "ProcName"
cmd.CommandType = CommandType.StoredProcedure

   ' Add any input Params...
cmd.Parameters.AddWithValue("@SomeIDParam", myID)

   ' Assuming Stored Proc returns a set of records...
   Using rdr As SqlDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
      While rdr.Read()
' do something with each rdr row ...
End Using

Now that we have this snippet it would be great if we could add this to the [VS2005] snippets.  The best way to do this is to grab the Snippet Editor from GotDotNet (not sure where this link will go when they close it down later this year, but oh well). 

Running the Snippet Editor will display a tree on the left which shows all the snippets which are currently in VS2005.  If you right-click one of the nodes you can "Add New Snippet".  You then have to give the snippet a name; in this case we use "Simple Stored Proc".  After creating the snippet you need to double-click it on the tree to open it in the edit window, as shown below (I've filled in some of the information textboxes on this screen).

At the moment the snippet is a great way to reduce the amount of code you need to write but doesn't really highlight the parts of the snippet that you need to replace.  For example it is unlikely when you use this snippet that you will be calling a stored proc with the name "ProcName".  To improve this snippet we can add replacements which will identify areas of the snippet that need to be replaced when the snippet is used. 

Using the Replacements tab of the editor is relatively easy.  You simply select the text in the edit window that you want to make a replacement (eg "ProcName") and select the + (Add new) button on the navigation bar.  This will allow you to spectify a name, default replacement and much more.  Once you are done your snippet editor window might look like the following:

For my snippet I've also added System.Data.SqlClient to the Imports tab and System.Data to the References tab.  This will ensure that appropriate imports and references are added to the project when this snippet is used.

Don't forget to click "Save" when you are done!

Lastly if you want to share this snippet with others in your team (or on your blog) you can click Export which will create a Visual Studio installer.

Test Your Knowledge of Visual Studio 2005

In case you haven't already guessed from the fact that this is my fourth post today I'm currently sitting in Heathrow airport on my way back to Perth. I must quickly add that this is the first time I have travelled around the world on the "One World" alliance and have been pleasantly surprised.  The two reasons I switched was because there is no local Star Alliance partner flying internally in Australia, and I now have Qantas Club membership.  The latter is probably more significant at the moment as it meant I was able to jump the 1 hour check-in line and the 30 minute security line - today was crazy in departures according to the staff. This said, I would avoid both American Airlines and Chicargo airport like the plague!

Ok, so now to the point of this post - One of the issues I'm seeing as more and more designers are added to [VS2005] is that there are an increasing number of "options" in the Tools->Options screen.  Thankfully the options screen is fairly accommodating and each new feature can have its own node, or sub-node, in the tree.  The question is whether you as a developer a) know these options are there and b) can find them.  So, I thought I would put my knowledge of VS to the test and go through each "option" and see if I can describe what it does. Note that each parent node simply displays the contents of it's first child, so for the purposes of this exercise they have been ignored....[This may span multiple posts, so hang in there]

Environment - General

Window layout: [Tabbed documents | Multiple documents] This controls how documents are rendered within the document (or main) area.  In the Tabbed case all documents reside in the same area; the user can switch between documents using the tabs along the top (and the dropdown at the end of the top bar). On the other hand the Multiple document layout is your traditional MDI child layout; each document appears as a separate window within the document area; windows can be tiled or arranged. In most cases the Tabbed case is preferred as you can achieve a similar effect to the Multiple layout by spliting the screen (horizontal, vertical or both). Note that even in Tabbed layout mode documents are treated as windows for the purposes of selecting the active Window using the Window menu.

Recent files - [1-24] items shown in Window menu: The number of documents shown at the bottom of the Window menu (above the "Windows..." option that opens a window selection dialog showing all open documents).

Recent files - [1-24] items shown in the recently used lists: The number of documents/projects that will appear in the recently used lists, namely the File->Recent Files and File->Recent Projects lists.

Show status bar: This usually appears in the View menu but since that menu is too busy with the numerous design windows (eg Solution Explorer, Toolbox) available in VS this option has been relegated to the options screen.  It toggles the status bar at the bottom of the VS window.

Close button affects active tool window only: For example the standard configuration is for the Solution Explorer, Class View and Properties Window to be grouped together on the edge of VS.  If this option is checked clicking the close button will only close the currently visible window.  Unchecked, all three windows would be closed.

Auto Hide button affects active tool window only: Similar to the previous option this controls the behaviour when you click the "pin" to hold an expanding window in place.  If this is checked then only the active window will be pinned/released when the pin is clicked.

Animate environment tools: This controls whether, and the speed if enabled, the tool windows are animated when they appear/disappear.  If VS is taking a while to open/close tool windows it is advisable to turn this off (in fact in 99.999% of times animation is just a PITA, so just turn it off anyhow).

Restore File Associations: In case you have assigned file types such as .cs or .vb (and a heap of others) to some other application this button allows VS to reassign them back to the defaults.  Unfortunately, unlike other applications that lets you know which file types it will affect, or even present you with an option as to which file associations you want, VS assumes it knows best and just goes ahead and does it.

Well, that was the General node of Environment; there are only like 100 or so more to do.... plenty of stuff to do on the plane.  For now I'm going to enjoy a glass of wine, some dinner and read a book before my flight.


     Environment - Add-in/Macro Security

Are Device Developers Second Class Citizens?

Some of you may remember that when [VS2005] shipped I had a few words to say about the fact that the Windows Mobile 5 SDK(s) weren't in the box.  Of course these decisions come down to what will/won't fit in the box (well on the ISO as in this case). With the release of the Windows Mobile 6 SDKs and VS Orcas just around the corner, will device developers have to download 2 SDKs if they want to work with both platforms?  The irony here is that at the core they are the same version of Windows CE, so IMHO there should be a single project type that handles both OS types!

Another interesting (but almost useless) bit of trivia is regarding the Remote Tools that are available for device developers.  I've often wondered why these are in the Start menu (Start->Programs->Microsoft Visual Studio 2005->Visual Studio Remote Tools) and not in the External Tools section under Tools within Visual Studio. Turns out this is another packaging decision: In order to ship within Visual Studio the tool must be available in all 9 languages that Visual Studio ships in.

Someone in the JCP forgot to maintain their server

Following claims that I'm an idiot, which I still believe is unfounded I decided to go and do a bit more research around Java, in particular the Java Community Process (JCP).  Having read a bit about the announcement that Sun is open-sourcing their implementataion (welcome the OpenJDK) I clicked through to the JCP information.  Well I clicked the link, what I got was:

Network Error (tcp_error)
A communication error occurred: "Operation timed out"
The Web Server may be down, too busy, or experiencing other problems preventing it from responding to requests. You may wish to try again at a later time.

For assistance, contact your network support team

Try again.... oh, this time the same address works but there is the following message at the top of the screen:

Attention: site maintenance is currently experiencing some technical issues. Please be patient while we troubleshoot them.

Clearly this should be taken as no reflection of the fact that this is a community process?



I'm an Idiot!

Stephen are you happy now?

I'll start by saying that while I might be an idiot I think that Stephen's comment was just childish.  Judging by his resume (which came up with "page not found" the first time I clicked the link .... what server is it running on btw?) I understand that his background is firmly in the Sun camp.  My original comment was actually an attempt at trying to get some educated debate.  In typical Sun, Apple (insert any other Microsoft competitor) fashion his retort is to call me names - great show of maturity.... he wins.

So, I'm going to take the bait and continue the original discussion around the choice of open-source or proprietary technologies affected the ability to create open-source software.  This discussion could be generalised to discuss the pros/cons of these choices in building any software. 

Ok, for the purpose of this discussion lets assume that Java has been open-sourced and that no one company is in control of its future direction.  On the other hand lets use .NET as the proprietary technology which is controlled 100% by Microsoft.  Let's examine some of the risks associated with these technologies. 

In the case of Java we have a technology that is disconnected from any particular operating system.  This means that in every case someone has to put in effort to optimise a JVM for a particular operating system.  This could be done by the OS manufacturer (oh, now hang on Microsoft did that but got slapped with a ruling that now prohibits them from doing it - Sun does know how to shoot itself in the foot ;-). Or it could be done by the Java community.  There might also be multiple JVMs for any one OS by different commercial providers, who then charge for the JVM which brings us back to the original point that Java was supposed to be the open-sourced side of the argument.

On the .NET side of the fence we have a technology that has been heavily invested into by Microsoft.  Now this is not to say that they won't change direction in the future but I would say that it is a fair bet that Microsoft will continue to invest in this technology for many years to come.  They have support for .NET in current and previous versions of their operating system - which clearly they do the work for as it maintains customer loyalty.  Interestingly enough, since the C# spec was put up as a standard, there is an open-source initiative to build a cross-platform runtime, Mono.  My last point on the .NET side is that you can build open-source software on .NET without investing in the Microsoft (or other 3rd party) tools such as Visual Studio .NET.

I'm not sure I've really layout my position here, just added some food for thought.  Again I would be interested in others' thoughts.  And please, if you are going to call me an "idiot", please don't call me a friend in the same sentence!

SQL Server CE Site Update

If you are looking at the Microsoft Sync Services which is likely to be part of Visual Studio Orcas you should check out the MS Sync Services FAQ across at  This has been updated to include the information posted by Steve Lasker on his blog. Steve also has a screencast which follows up from my previous post that looks at the sync designer.

Logging options for .NET Compact Framework

Since the first coffee meeting I have been hassling Alan to start blogging.  After migrating the user group's website across to Community Server I was able to set a blog up for him and he just submitted his first post.  One of the pain points for a number of mobile developers is what to use for logging.  Most developers end up doing their own custom solution.  At Intilecta we ripped out most of the useful bits from the Patterns and Practices Enterprise Library.  Based on what Alan has to say in his post I think I would definitely look at log4net as it seems to be quite comprehensive and it runs on the .NET Compact Framework.

SQL Server CE as a testing tool

I noticed that DevPrime has posted an interesting comment about using SQL Server CE (SSCE) is as source database for test data. This was followed up with some comments by Jay Kimble regarding taking a snapshot of a SQL Server database and pushing it into a SSCE database.

From DevPrime's comments it implies that there might be stored procedures in the next iteration of SSCE.  Given what is available in the current March CTP of Orcas I would doubt if this is true.  Given that SSCE is typically used as an in-process database, is there any real benefits to having stored procedures and/or triggers for that matter? 


Source control up-time

As I indicated in a previous post we have recently moved away from SourceSafe and started using Subversion.  Since my involvement with the VS2005 betas and using TFS for a couple of small projects I have always been an advocate but there are a couple of things that just don't make it the right decisions for most SMEs.  The first obvious hurdle is the price but I think this is only a minor issue now that Microsoft have a great partner pricing program where you get a TFS license and a number of CALs depending on your partner status (I think it is 10 for certified and 35 for gold partners).

More important than price are the limitations of v1 of TFS.  The two that come to mind are:

  • One of the things that staggered me when I was using it was that there was no built in build scheduling - I would have thought that this would have been a fundamental part of such as system.  The build system should be able to be triggered based on certain events (not just code checkin, perhaps event work item status change?).
  • No support for working offline.  There is support at the project management level as you can export lists to excel, work on them offline and then sync them when you are again connected.  Unfortunately you need to use a power toy to enable offline support for source control.  And even then it isn't true support (as I understand it).  The TFS team really needs to look at how Subversion works - yes that's right Steve (Intilecta's Development Manager) I'm a convert now!

Microsoft, if you really want to work in this space there are some significant issues to be addressed in vNext of TFS to make it a compelling business decision.

(Oh, by the way Grant, Intilecta's SourceSafe (unpatched) repository is just marginally older than your process ;-)

Java is no more open source than .NET

This afternoon I found myself reading an article at The Spot 4 SAP entitled SAP Mobile Engine.  Leaving aside the fact that the article hasn't been written very well at all I want to comment on their continual reference to the Java platform as an "open source technology".  Now the last time I checked Sun still owned the rights to the language and it was their decision as to the changes that are made (please correct me if I'm wrong as I haven't worked in the Java space for quite some time). 

I would like to make the comment that it is possible to write open source software with either Java or .NET and that they choice of technology should in no way affect the identification of the software as open-source.  It really annoys me when journalists just don't get it and claim that just because Java is a "standard" that can be implemented by different vendors it is in any way more open-source than .NET.

Updated: I was pointed to the Open-Source Java Project which is the process by which Sun has announced that it will release its implementation source/details to the community.  At it points out the role of the JCP will not change.  I guess this shows my first point up as being a little inaccurate.  I still hold by my second (and IMHO more important) point which is that you can write open-source software on any technology.  And further I don't believe that by choosing an open-source technology on which your commercial application is necessarily a sound business decision.

Prime position at Barnes and Noble

As I have an extra day here in Seattle following the MVP summit I decided to wander around town and explore the shops.  Of course the first comment is that every second store is a Starbucks, and of those that aren't Starbucks, every third store is a "Seattle's Best Coffee".  The department stores are much bigger than back home and there is both a Borders and a Barnes and Noble within two blocks of where I'm staying.

Since becoming a published author I can't resist the urge to drop into these large bookstores to see if they have my book.  I was pleasantly surprised at Barnes and Noble that they not only had 3 copies of my book, it was also in a prized location on the shelf (I just had to take photos....):

In the past I have only even included the link to Amazon but you can order Professional Visual Studio 2005 online at B&N.

More March Orcas CTP

In my last post I left you hanging to see what would happen when I created a new .sync item from the Add New Item dialog.  So here you go, the following is what the synchronisation configuration screen looks like in the March CTP - bearing in mind it is likely to change, so if you don't like it say so at

For anyone familiar with the MS Sync Services you will immediately see that under Database Connections you can define both a server and a client connection.  This uses the same set of connection strings that are defined within you app.config file for you application.  You can either use an existing connection or create one using the New button.

Under Synchronisation we have the option of specifying how frequently a synchronisation is attempted.  There are a whole bunch of different rules that could be used to define when a synchronisation should be executed so I suspect that this is too simplistic for most developers.  The last option here is the "Synchronize tables in a single transaction" - this can be particularly important where you have relationships between tables (for example orders and order details) and you want to make sure you either get everything or nothing (ie all my order information, or none at all).

Clicking the Advanced + button expands out the dialog to include the following settings:

One of the nice features of the MS Sync Services is its ability to be split so that the client and server logic doesn't all run locally to the application.  This might be across webservices, wcf or the macaroni protocol (basically it doesn't matter how the data gets there so long as it does).  The advanced settings allows us to configure how the designer generates code.  For example you could elect to only generate client, only server or both client and server code.  You might want to split the code across two projects (for example the client code might be in the application assembly, which the server code might be in a supporting webservice project). 

Going back out to the main dialog we can see that there is an Add Item button.  This opens the following dialog which allows us to specify which tables from the server we want to synchronise to the client.

As you can see there is only one table in my database, called Attachments.  The designer uses the Sync Builder to generate the Sync adapters it needs.  As such this dialog is really configuring the Sync Builder so that it can in turn generate the appropriate Sync Adapters.  For more information on how the build works, and as such how these parameters work head across to the MSDN Forum or to and subscribe to the Sync Services FAQ.