This blog has, IMO, some great resources. Unfortunately, some of those resources are becoming less relevant. I'm still blogging, learning tech and helping others...please find me at my new home on

Monday, November 23, 2009

Talking Shop with Scott Guthrie

I’m in an online session right now in the LIDNUG group with Scott Guthrie who is answering questions related to PDC announcements, ASP.Net and Silverlight. 


I asked him about a couple of things, here are his responses:

  1. Will there be better tooling for ASP.NET MVC 2 Areas in the IDE?
    1. Yes, some of those tools were released with the last bits and Scott has a blog post coming up on that soon.
  2. The level-of-depth for the Nerd Dinner MVC example was great for beginners, but we don’t all need that level of depth for MVC 2.  For the next version can there be a walkthrough for people with more development experience?
    1. Yes, in an upcoming blog post Scott is going to do a feature walkthrough, highlighting what is important and why in MVC 2 without the introductory-level code bits.

Sorting Out Entities with Multiple Relationships in LINQ to SQL

There is a very common scenario in data design where you define a table as having two relationships with a single (other) table.  This especially comes into play if you have anything in your model with an “assignment” where someone assigns something to someone else.

In this case, We are tracking work tickets that are created by someone for someone else.  Both are stored in the ticket table.


Above is a snip from the DBML designer for LINQ to SQL. The two arrows represent the relationships between Person and Ticket, namely, that CreatedFor and CreatedBy are Person references.  If you have set up the foreign keys in the database, these associations are created for you automatically.

Convenient, yes, but code-revealing, no.  Here’s the result of the default naming as a result of the relationship being automagically created:


Now, which is which?  Are you looking for Tickets or Tickets1?  The default method for selecting a name is pretty ambiguous.

Directing LINQ to SQL Naming

Thankfully, the designer gives us a way to control the code generation tool and its naming conventions.  Click on one of the association lines on the DBML canvas and look at your properties windows.  Verify the members that are in use in the “Participating Properties” property, then drill into the Child Property detail.

There, you can set the name of the Child property to something more meaningful to developers using your code down the road.  Or, for yourself six months from now.

image You also have a chance to disambiguate the Parent property.  And, as a result, you have more readable syntax working from the child and walking to the parent record.

Wednesday, November 18, 2009

SqlGeography and Linq to Sql

I have a love-hate relationship with Microsoft SQL Server 2008’s Geography type.

I love working with it, but I hate it’s inaccessibility with some of my other favourite technologies. 

Specifically, I am trying to store GPS co-ordinates in the database as geography types.  This is a simple use, however, and although I’m only using points right now, we have other, more complex shapes that we must store.

I have figured out a couple of workarounds (that really aren’t workarounds at all) that allow me to use tables with the geography type in Linq to Sql.  These only really work for the point type and would get increasingly arduous as the shapes contain greater complexity.

Making SQL Server’s Geometry Play Nice with Linq to Sql

Unfortunately the Linq to Sql provider does not contain the data type support required for geometry or geography.  We’re not left with many options, at that point.

I tried a couple of hacks by creating the table by hand in the designer (it won’t let you drag the table onto the canvas) and stubbing in the field as a string, then banging up the code-behind to make it jive with the right types.

No go.  At the provider level it is not happy and there is no visible way to coax it into supporting the type.  Even if you cross your fingers AND your toes, you still get an error to the tune of:

The specified type 'geography' is not a valid provider type.


So, we’re stuck with less-pretty approaches.  I’m going with number one.

  1. Use Lat and Long as float types in the tables.  This allows seamless use in the Linq-to-Sql editor.  Create views that represent those columns as a single geometry point for reading the data in non-Linq-to-Sql scenarios.
  2. Store the co-ordinates in a geography field in the table and use stored procs to read and insert data as floats (lat and long).  Convert the data in the procs both ways.  Add the procs to your DBML.  This isn’t as good, because we lose some of the coupling in being able to ‘walk’ across your model in code.

I have also seen a recommendation to store the geo data as xml in the database and then do conversion on the client (casting to the proper types in code when needing to tap the data), or even pushing the data around as varbinary.  This approach would work, but generally I’m working with points right now and won’t need the added complexity.

Future Versions of Linq to Sql and Geometry

There have been suggestions from Microsofties on the forums that there will be support for these types down the road.  Right now, I’m sure it has to do with the fact that the assembly you need to access the type isn’t in the GAC by default and can’t be relied on to be present when someone’s in the throws of development (must have SQL Server installed to even get at the assembly in question).  Perhaps promoting the types to a more common distribution surface would alleviate this and open up the designer (and provider) to supporting them.

For now, Visual Studio 2010 Ultimate, Beta 2, does not have the support added.

Rx Comes to Fruition

The RxTeam last night announced the official release of the Rx Extensions (which has been called the Reactive Framework as well as the Rx Framework).  Developers now have a suitable set of tools – complete with concurrency support – for tackling asynchronous computation scenarios that respond to UI- and UX-driven events (or anything else that you need to subscribe to).

We no longer have to use the IL-hacked version of the library that targeted the Win-friendly version of mscorlib.

If you haven’t used it or heard of it already, Rx is the baby of Erik Meijer, the brains behind Linq.  The library is a collection of extension methods, interfaces and helpers that let us (subscribers) listen to events (publishers) in a Linq-friendly and developer-friendly way.


Above is the picture of Erik.  I wanted to post this snapshot of the video to ensure that t-shirt was recorded for all of mankind in the future to witness.   Assuming they will read this blog, that is…

The process of developing a standard library to encapsulate the long-standing Observer pattern went through many cycles between many teams.  The result is a set of extensions that flow seamlessly through from what we already know about working with collections: the Linq methods we have been working with for the last few years have been ported over to the Observable bits.

In addition to that, some new helpers and methods were spawned from the process that served IObservable really well.  Because it is the dual of IEnumerable, the team saw benefit to back-porting that functionality to original interface.  Read another way: IEnumerable isn’t being left behind as the dumb older brother.  The old dog is learning new tricks.

A lot of learning ahead, folks, get the bits and start playing!

Friday, November 13, 2009

Reactive Framework –> Hello World

Here’s a really quick sample on how to get into the upcoming Rx Framework, aka the Reactive Framework.  I’m using System.Linq.Observable as the source object to “observe”.


To get this to run, download this version of System.Reactive (re-jiggered for the non-Silverlight folks), create a console application and paste the code below in Main.

var cookiePieces = Observable.Range(1, 10);

cookiePieces.Subscribe(x => Console.WriteLine(
"{0}! {0} pieces of cookie!", x),
ex => Console.WriteLine("Never going to happen in this sample..."),
() => Console.WriteLine("Ah! Ah! Ah! Ah!"));


All we’re really doing here is a little pump that executes 5 cycles and exits.  The Observable class implements the IObservable interface and gives us some structure to test again (like they do in the Silverlight bits that came out in the summer).

I’m exploring the framework more and more and working through several composition scenarios.  I’m liking what Rx has to offer at this point, especially the bits that allow for the extension of Linq to events.

Friday, November 6, 2009

Installation of TFS 2010

If you’re installing Team Foundation Server 2010 and you run into error TF255352 you might have a problem with your firewall.

Here’s the text of the message:

Permissions could not be verified because an error occurred while communicating with the following report server: [my server] 

And also, in a second warning:

The server returned the following error: The report server cannot open a connection to the report server database. A connection to the database is required for all requests and processing.

I missed a step in the install guide (how can you not…it’s just under four billion pages hehehe) and didn’t configure my firewall.  After adding the required port exceptions, I reran the pre-check, got all green lights, and installation continued as planned.

A Little Too Hot

Thankfully our servers didn’t suffer the same fate as the folks down under at Designwyse (the picture links to a Gizmodo article), but we came into the imageoffice this morning to find our server room A/C unit blowing hot air.  Ouch.

Most of our internal network was limping and we had general connectivity problems, VOIP issues, etc.  General yuck stuff you have to deal with.

The UPSs were failing, all the Dell server equipment we had was shutting itself off (overheating preventative measure) and our chassis temperatures were all over 50°C (that’s over 120°F) and alarms were sounding.  The room is 12x10 with about over 50 servers in it.  The metal on the racks was hot to touch.

Methinks the redesign on the server room and A/C upgrades planned for early next year might be getting bumped up in time frame…

Of interest, our Big Bertha that handles virtualization did a great job.  She’s taken over 20 machines on board (most physical-to-virtual conversions) and I can’t imagine how how it would have been in there if there were another 20 machines running.  It could have been disastrous.

Thursday, November 5, 2009

Apple Will Ruin the World

image A very startling realization came to me yesterday: Pixar Animations Studios has prophesized that Apple Computer will spell the end of Planet Earth.

By now, you’ve likely seen the movie Wall-E. The story takes place 700 years into the future where humans have lived in the outer reaches of space for several centuries, mostly unaware of the plight of the planet they once called home.

We are introduced to the main character and join him as he makes his way through a typical day, compacting garbage, making building replicas and collecting interesting bits of junk.


So…what is Apple’s part in world devestation?

You might be wondering how this ties into my theory. Who cares if a little robot is left here to clean up our mess? And what does that have anything to do with Apple? Well, let’s look at it from another angle:

  • Why did the humans leave Earth? There was too much garbage.
  • Why was there too much garbage? Because Buy-n-Large convinced consumers to buy into a perpetual model of perceived obsolescence (“Wear red, it’s the new blue!”). Everyone replaced everything without caring about anything. Buy-n-Large had them trained perfectly.
  • How did Wall-E learn about humans? He watched videos rigged up with an iPod.
  • Did he know a lot about iPods? Of course, he had it wired up to not only view stored content, but indirect input from VHS tapes and players. This cat had intricate knowledge of the device…he almost knew it’s inner workings too well…
  • Did he have a deeper connection to iPods at all? Well, maybe not, but he makes the Apple start-up sound when he wakes up.
  • Wait! The Apple start-up sound? Yes, one in the same.
  • But I thought Buy-n-Large made all the Wall-E units to clean up planet Earth?!

…and then BANG! You get it! Apple IS Buy-n-Large. Just as many people I know are on their second, third (or more) iPod or iPhone, Apple is already convincing people that the things they buy are legacy the moment it comes home.

It’s easy to see what would happen to Earth if Apple becomes the conglomerate, all-goods store that they do in the movie Wall-E. People already buy into their model of things becoming junk in just months or years.

image Long gone is a time when people would patch jeans or take shoes to a repair shop. There’s a whole new class of disposable electronics – DVD players, ink-jet printers, MP3 players – and we’re pretty much headed on a crash-course with garbage overload.

Just as Pixar suggests, with Apple hiding behind a name as blatantly anti-Earth as “Buy-n-Large”, by purchasing Mac Products you will help Steve Jobs bring an end to this planet.

There, glad I got that off my chest.


…and by the way, this is the most tongue-in-cheekiest post I’ve ever made. Play along, it’s just for fun! ;o)

Wednesday, November 4, 2009

A Simple Image Display

In response to a forum thread on MSDN, I wrote a quick app that uses two quick methods to display a picture on a form.  The solution (Visual Studio 2008) is available for download here.  The class in question is System.Drawing.Graphics and the forum member was simply looking to display an image.

The app is pretty simple:


One method (Easy Open) loads an image from a file and sets the Image property of the PictureBox.  The other method (Harder Open) loads (and caches) and image to a member variable and keeps it around for a custom paint event on the PictureBox.

The poster also mentioned some performance metrics, so I stubbed out some placeholders for that as well.

Visual Studio 2010 Goody Bag

A couple of quick things that you’re going to like when you start using Visual Studio 2010…

Visual Token Recognition

  This is a form of syntax highlighting that exposes variable use throughout the current class file.  This is actually a significant boost when you’re trying to assess the potential impact of a refactoring.  You can place your cursor on the member definition and every instance of the token will be highlighted throughout your file.


Even cooler is that it works not just on variables but also on other tokens, such as methods and properties:


You may also notice from the above shot that your cursor doesn’t have to be in the method/property/variable declaration; in fact, if you cursor into any member usage, all other instances are lit up.  Brilliant.

Collapsible Section Highlighting

Here’s another visual enhancement (it is subtle, so it will be hard to see on a non-contrasty display):


Okay…artiste, I am not.  But I had to draw in the cursor where it was hovering when I got the block of code to light up.  There is a light-grey highlight behind the entire collapsible section.

More Ways to Learn the Code

imageIf you’ve ever been assigned a defect on a system that you are new to or haven’t worked on in a while, it doesn’t really matter how experienced a developer you are, you’d probably enjoy a bit of help.  The above enhancements are good tools for that. 

So are these: Generate Sequence Diagram and View Call Hierarchy.

Both of these features are available from the right-context menu of the code editor in Visual Studio 2010.

The call hierarchy is very similar to the debug experience in previous versions of Visual Studio in that you can see where the code walks from where you’ve queried.  This is a bit different from the debug version, where your hierarchy are inferred from the current execution point.

imageThe Generate Sequence Diagram feature is a great aid in discovery as well and a welcome addition. If an SD is one of your deliverables, I can assure you that it’s just as slick as the View Class Diagram feature from previous versions. Though they can get quite complex if you fully include all options, they can also be very descriptive – including code snippets – and will give any viewer a good idea of the execution path for the areas of your software you’ve included.

Several external tools have been created over the years, and some of us have had to slog away in things like Visio before (which is where I did my assignments in my UML courses. Echk.)

If You Don’t Use These, It’s Only Because You Don’t Use Them YET.

Right from the start Visual Studio looks and feels like it will provide developer productivity improvements.  While productivity is usually a seller for management, these types of improvements are actually good for developers and equip us to better navigate our code, legacy code and code that you might fear.  Because the IDE allows us to target different versions of the .Net Framework, we can also leverage these gains on older projects.

Monday, November 2, 2009

Restoring RSS Feed Syncronization

One of the things I really loved about Outlook in Office 2007 and the release of Internet Explorer 7 was the marriage between the two with the concept of the Common Feed List from Windows. Unfortunately that seemed to go away with Internet Explorer 8 and Outlook 2010.  While troubleshooting another issue I came across the option to sync the RSS feeds in Outlook with the CFL:


image To locate this, you need to get at the Backstage (learn to love it!), hit Options under Outlook and then navigate to the Advanced menu as indicated above. Make sure you have Synchronize RSS Feeds to the Common Feed List (CFL) in Windows checked off and bing! you’ll have all the feeds you subscribe to in Internet Explorer automatically downloaded in Outlook.

Don’t use this feature?  You should!  Check this out: when you go to your favourite blogs or news sites in Internet Explorer 7 and up you will most likely see the RSS feeds button light up.  It’s located on the same line as the tabs are, next to your Home Pages icon.  If there are multiple feeds, there will be a dropdown box that will give you options.  For instance, when I check out Gizmodo’s home page I see this:


When you click on any of the feed choices, you see the raw feed, almost detached looking from the main site.  At the top of the new page you’ll have an option to subscribe to that feed and forever be at oneness with your favourite site.


Go ahead, try it here! ;o)

No Luck Resolving a Windows Mobile Sync Issue

I had installed Microsoft Office 2010 Technical Preview prior to my upgrade from Vista x64 to Windows 7 x64.

I have an HTC Touch Diamond running Windows Mobile 6 that I have set up to sync with Exchange.  The sync continued to work after the upgrade to Windows 7.

Yesterday when I stopped by the office for a few minutes I installed the new version of Windows Live Messenger, which now comes packed with the rest of the Live applications.  Not thinking twice about it, I went ahead and let it all install, including Windows Live Mail.

Now, when I try to sync, I am getting this error message:

Either there is no default mail client or the current mail client cannot fulfill the messaging request. Please run Microsoft Office Outlook and set it as the default mail client.


It occurs whenever I connect the phone to the computer.

It doesn’t bother me terribly; I have tried a number of things (adding/removing contacts, pushing files, taking pictures to a sync’d folder, etc) and it all seems to function correctly.  I am, however, nagged by this dialogue every time I connect my Windows Mobile device.

Is Windows Confused?

I think it might be that there are some funky associations going, maybe that Outlook and Windows Live Mail are trying to fight for the real default for mail?  Dunno…

I went into both applications and tried setting them as the default. I went into the default programs from the Control Panel and also tried making Outlook the default from there.  The dialog persists.

Next, I found this blog post which seems to have 50/50 success from the comments.  It involves a registry edit and running Office Diagnostics (which unfortunately doesn’t appear to be in the Technical Preview for Office 2010).  This trick, it seems, actually made it worse for me as Outlook wasn’t able to rebuild it’s registry keys.  Luckily, I had made a backup of the keys prior to nuking them as suggested in the article.

Symantec offers a work-around that may work, but is really just a way to suppress the error message by renaming a different key in the registry.

Maybe it’s not Windows or Outlook

I do recall a warning about Windows Mobile Sync Center in the upgrade advice from Windows 7, perhaps this is one of the side effects of whatever that warning was about.  At any rate, I haven’t been able to nail down the culprit or find a suitable fix.

Ideas, anyone?

SQL Server Diagramming Wishlist

It can be a frustrating experience using the diagramming features of Microsoft SQL Server Management Studio.  While there have been great improvements in stability and the generated SQL syntax on edits, there leaves a lot to wish for in layout.


Above, I have laid out some of the tables being used in an application I am working on.  The key concept I am trying to diagram in this layout is the concept of a Contact.  It is placed in the center near the top because it is the Most-Important-Table.  Groups of tables in closest relation (by my definition) are placed closer together; peripheral tables are spaced out.  Visually, this works for me and my team and we can see the information on one screen or one printed page easily.

The Problem with Auto Arranging

If I were to use the Arrange Tables feature in MS SQL Server Management Studio, it would redraw my tables as such:


You can see that there is little regard for overlap, I have to zoom out two levels further to see most of my tables and two tables are actually not in view at all.  They are laid out more vertically and will need some serious love if anyone is ever going to look at this for more information about our project. 

Worse still, you can’t tell by looking at this what the Most-Important-Tables are.

A Solution For Layout

First off, I have to admit that when you drop a dozen or so tables onto a diagram and hit Arrange Tables it does a good enough job of moving things around and giving you some space to work with the tables.  But the story shouldn’t end there.

Imagine a Layout Wizard that you could invoke, one that would ask you what the Most-Important-Tables are and then allow you to quickly group tables together that are related not because of high referential counts, but because of business logic.  The wizard would even suggest groups and the Most-Important-Tables.  You would be able to quickly define groups and drag table names into them.  It wouldn’t be responsible, during the information collection, to draw anything out; it would just seek some input from the user.

Take that one step further: create an active layout engine where a tool window allowed you to alter those inputs and change the diagram on the fly.

Improving the Team Story

MS SQL Server Management Studio, especially at the SQL Server 2008 level, is a powerful tool that has grown a lot, but has a lot of room left to grow.

Better automation around the diagramming story – or perhaps, simply more automation features – would help teams better understand concepts related to the part of the model they are working on.  It would allow easier creation of “throw-away” diagrams when new team members are brought on board.  It would allow people unfamiliar with the data model to explore key concepts and more quickly gain an understanding of how the pieces fit together.

Sunday, November 1, 2009

Control Panel Pinning in Windows 7

I love finding the little things that make a lot of sense and improve workflow. Windows 7 enhancements to window management as well as application launching are solid and more than welcome. 

Get at things, all fast-like

imageIn Windows Vista I was able to pull down the icon from a Control Panel tool that I used frequently and drop it on the Quick Launch bar.  This allowed me to jump into something like network connections without having to go through two or thee windows and clicks. I used this a fair bit for testing multiple resolutions and switching between networks (and more) so I would have multiple shortcuts created

imageWith Windows 7, we see this feature further enhanced with the addition of pinning.

When you right-click-drag the icon down to the launch bar, it no longer creates a short-cut…not exactly anyways.  You are prompted to “pin” the component to the Control Panel icon.

Finally, any of the items in your “Recent” list can easily be pinned.  So, if you’re like my mom and you can get the hang of a right-click-drag, just go about getting into the component the way you normally would and then pin it to the Control Panel list on on the launch bar.

This works well with most Windows 7-aware applications, so be sure to try it out in other places too.  You can discover different ways to get into applications by right-clicking on the icon if it’s in your launch bar.

A real good mix in Windows 7

Inspiration for the docking, the launching and the window management features of Windows 7 comes from all over.  I’ve seen elements of its behaviour in other operating systems, touch-screen interfaces and even in works of fiction.  I would argue, however, that Windows 7 may have one of the best systems in place for getting at your applications, utilities, and even data in your documents.

Unlike prior versions of Windows and some competing O/Ss, Windows 7 makes it easy…and it looks good.