Anything related to the .NET framework

Install Tailspin Travel on Windows 7 SP1

Submitted by Robert MacLean on Tue, 04/05/2011 - 17:16

imageIf you try and install the tailspin travel demo on Windows 7 with service pack 1 , it will fail saying the operating system is not supported Sad smile

Thankfully this is easy to fix, in the C:\TailspinTravel\assets folder is a Dependencies.dep  file. Open that in notepad (or text editor of your choice) and navigate to the <os> element. Note the buildNumber attribute is set to: 7000;7100;7600

All you need to so is change it to: 7000;7100;7600;7601

As in the screenshot above, now save and rerun setup and you will succeed!

How to attach to process before the application even starts?

Submitted by Robert MacLean on Wed, 03/30/2011 - 12:35

There is many ways to do debugging in Visual Studio, normally you just hit F5, compile & run the code with debugging. However sometimes you need to debug an executable you have already built or debug on another machine. I have mentioned this previously you can use the Attach to Process option to do debug MSCRM assemblies that exist on other machines and/or run by a executable you do not control.


This works great but recently I had an issue where the application would start and (silently) die within seconds, but only in test (never in dev). It just happened so quickly that I could not attach the debugger in time. So how can you debug that scenario?

Thankfully this is very easy, just go to your Visual Studio project settings and switch the Start Action to Start External Program, set the path to the executable and then hit F5!


What this will do is start the executable, attach the debugger and work with your code all for you – so no more racing against the attach to debugger options Smile

Missing Code Analysis

Submitted by Robert MacLean on Wed, 03/30/2011 - 12:29

If you have Visual Studio 2010 you may be annoyed when you want to run code analysis and it is just not there! You can configure it, but cannot run it?!


The reason is that code analysis is only available for the selected project, and you likely have the solution selected in the Solution Explorer (or Solution Navigator). You will need to select the project first and it will appear.


No solution wide code analysis yet either. However I believe these annoyances will be corrected in the next version of Visual Studio Winking smile

NDepend: Power tip to analyse quickly

Submitted by Robert MacLean on Wed, 03/30/2011 - 12:25

Update: This has changed with version 3.8, read the awesome news at A follow up to my NDepend pro tip...

I am a a big NDepend fan – I can’t imagine doing analysis or taking over new projects without it! If you have not heard of NDepend, then have a look at: NDepend - The field report

I feel stupid for not finding this power tip before, but recently I had about 20 projects to analyse - a situation that appeared to be painful because it meant creating NDepend projects for each one.

Thankfully I stumbled on the terribly named Select .NET assemblies to Analyze option in the file menu. This is option is actually a way to create a quick temp NDepend project!


Once you have clicked that, you should click the choose VS solutions option and you get another great dialog showing you a list of your Visual Studio recent solutions! This is great because I would load the code in VS, build it (to make sure it can build) and run code metrics against it and having this quick selector linked to VS meant that I do not need to browse for the solution NDepend again!

Possible bug in it though, where it doesn’t show web projects; WinForms, console apps etc… all fine just not web projects?!


Select the one you want, hit OK twice and analysis starts!

Happy analysis!

Pepper: A Visual Studio Settings Synchronisation & Backup Extension

Submitted by Robert MacLean on Wed, 03/23/2011 - 10:53

pepperscreenshotPepper is a new free extension for Microsoft Visual Studio 2010 that I have created to solve a major pain which I am calling SLM (setting lifecycle management Smile with tongue out). The problem is that settings inside Visual Studio are vast & complex, and configuring your IDE is a labour of love, taking years of fine grain tweaks. I can personally trace back my settings to sometime in 2005 and have been tweaking and fiddling ever since.

Once when I moved jobs I forgot to copy my settings and VS felt broken until an ex-co worker was able to get a backup of my old laptop restored and sent me the file. Wouldn’t it be great to have a backup system in the cloud? Say on Azure?

This brings about another interesting scenario, what if I have multiple machines? Can I backup on one machine and restore on another? Giving me a synchronisation system for Visual Studio settings?

Pepper does exactly that, it automates the export/import of settings and allows you to place them in a SQL Azure database!

This is the first release, and while it has had some beta testing it is not perfect so please, if you give it a go and it fails, let us know in the discussions.

Pepper is available in the Visual Studio Gallery, which means you can install it and keep it up to date inside Visual Studio too!


Visual Studio Recent Settings

Submitted by Robert MacLean on Thu, 03/17/2011 - 11:17

When you use the import settings option inside Visual Studio, you may notice a long list of settings Recent Files with no way to clear them out.

If you do want to clear this out, you can do this by going to the following registry key:


Note this is completely unsupported, but I have done it without any issues.


SharePoint Holiday Loader

Submitted by Robert MacLean on Mon, 02/21/2011 - 12:33
March 19, 2012: This tool has had a major make over since the original release!


I’m sure, as a SharePoint power user, you’ve had the fun of your boss walking up to you and asking why the public holidays aren’t in your SharePoint calendar? (guess what happened to me last week)

You would think this would be easy, in fact Outlook supports adding holidays to calendars easily. So why isn’t SharePoint easy like that too?

I’ve had this asked a few times and never had a good answer to do it, so I decided that a simple tool needed to be built to solve this once and for all – Let me introduce SharePoint Holiday Loader (SHL).

SHL takes a standard holiday file (.hol) and allows you to publish that to a SharePoint list!


This tool is very easy to use (just need the file, the server and the calendar name) and it is free and open source. You can get the download the tool, source code, leave comments (or complaints) at: https://bitbucket.org/rmaclean/sharepoint-holiday-loader/

Dev4Devs - it's coming!

Submitted by Robert MacLean on Thu, 01/20/2011 - 09:13
Update: Event moved to the 5th March 2011 - details: http://blogs.msdn.com/b/southafrica/archive/2011/01/18/devs4devs-returns.aspx

Dev4Dev’s, my favourite event, is coming up soon! It is a free event which happens at Microsoft offices on a Saturday morning where you get to see a variety of topics! The key points that make this awesome:

  • Each presentation is 20min long – so all meat in the topics with no fluff!
  • Even though it is as Microsoft, it is not Microsoft – some fantastic non-Microsoft technologies has been shown before.
  • It’s developers presenting to developers – so no marketing nonsense.
  • You can apply to present in one of the slots – so if you want to present at bigger events (TechEd, DevDays etc…) this is a great way to get on the radar of those who make those decisions!

All the details at: Devs4Devs Returns

For me this is the first one I will miss as I will be in Seattle for MVP Summit Sad smile

What's in Microsoft.VisualBasic for C# Developers: Part 7 - File System

Submitted by Robert MacLean on Wed, 01/19/2011 - 10:52

monolith_thumb[This blog is part of a larger series, to find more parts in the series please see the Series Index]

The FileSystem class is what originally brought me to explorer this assembly because there is some very interesting options in the class which aren’t available elsewhere. To add to confusion there is two FileSystem’s in the Microsoft.VisualBasic namespace Confused smile:

  • Microsoft.VisualBasic.FileSystem
  • Microsoft.VisualBasic.FileIO.FileSystem

The one I am interested in, and this post covers, is the second one which has some fantastic options: unfortunately there is way more functions in there than a single blog post can cover (27 methods not counting overloads), so  I am going to focus on just two of them which bring new features, i.e. not just wrapping some other .NET API.


imageThe first I want to look at is the DeleteDirectory method which allows you to easily delete a directory. What makes this fantastic is that it can empty the directory of files first (i.e. it handles non-empty directories). Second it supports deleting to the recycle bin and finally it supports a nice pretty UI for the deletion action, including confirm dialog and progress bar dialog.

string testFolder = FileSystem.CombinePath(Environment.GetFolderPath(Environment.SpecialFolder.Desktop),"Demo");
FileSystem.DeleteDirectory(testFolder, UIOption.AllDialogs, RecycleOption.SendToRecycleBin, UICancelOption.ThrowException);

In the code above uses a few options from FileSystem.

  • CombinePath – this is provides a error checked and normalised concatted path using System.IO.Path.CombinePath.
  • CreateDirectory – this does some error checking and wraps System.IO.Directory.CreateDirectory.
  • DeleteDirectory – This is what we are talking about with the display of UI and send to recycle bin enabled.

There is similar methods to DeleteDirectory, such as MoveDirectory  & CopyDirectory and similar items for files: CopyFile, MoveFile etc…


This is a very useful function which allows you to search files on your machine for specific content (i.e. search in the file, not just the filename). This is not wrapping any functionality behind the scenes (for a change):

string myDocs =Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
var result = FileSystem.FindInFiles(myDocs, "MVP", true, SearchOption.SearchTopLevelOnly);

MessageBox.Show(result.Aggregate((c, n) => { return c + Environment.NewLine + n; }));

The above code shows me searching the My Documents folder for any file with the letters MVP (in any case – controlled by the third parameter). It can be filtered using standard wildcards and and search sub-directories too Smile


What's in Microsoft.VisualBasic for C# Developers: Part 6 - Networks

Submitted by Robert MacLean on Tue, 01/18/2011 - 09:14

monolith[This blog is part of a larger series, to find more parts in the series please see the Series Index]

The Network class is an interesting set of wrappers around other classes in .NET which is useful for simplification of certain actions:

  • DownloadFile & UploadFile
  • Ping
  • IsAvailable

DownloadFile & UploadFile

These two methods are interesting in that the wrap the WebClient class which make it much easier to use while still giving a lot of flexibility. This isn’t the most robust way to work with the HTTP (download) & FTP (upload) but it is very useful. For example the easiest way to download a file:

Network network = new Network();
network.DownloadFile("http://www.bing.com", @"c:\bing-index.html");

It includes 10 overloads which the most complex is:


One of the interesting parameters I wanted to highlight is the showUI parameters which when set to true gives you a dialog ox with a progress bar and cancel support. It’s not pretty but, like a lot of this Network class it is functional:



Just like DownloadFile & UploadFile, Ping wraps other functions in the framework, namely the Ping class from System.Net.NetworkInformation. It really just takes two lines of code if you used the Ping class and makes it two lines using the Network class – not really that helpful:

Network network = new Network();
string message = network.Ping("www.bing.com") ? "Bing is up" : "Bing is down";


The last in the Network Trilogy is the IsAvailable property which tells you if you are connected to a network. All it does is call: NetworkInterface.GetIsNetworkAvailable.

Why you want to write two lines for this when you could use the one line it uses is confusing, but it’s there:

Network network = new Network();
string message = network.IsAvailable ? "Network up" : "Network down";

// I prefer this:
string message2 = NetworkInterface.GetIsNetworkAvailable() ? "Network up" : "Network down";