Category Archives: .NET

Opening a TFS 2010 build process template in Visual Studio 2012 – Update


A little while back, I posted here about resolving some issues that come up when opening up TFS 2010 build templates for the first time in Visual Studio 2012.

There are two more tips I need to mention that helped me with resolving these issues.

During my last post, I indicated that a tip to help resolve this problem was to re-select some of the TFS Object types in the Variables/Arguments windows.  In addition, you’ll see that the version of these types still point to [].  With VS2012, the TFS reference version have been bumped up to, so this means, we need to do the same with our references.

In my case, I house all my build templates under one umbrella project, which has several TFS references, and as you can see, still points to version 10.


Simply remove and re-add these references with their version counterparts (screenshot below).

TFSReferencesNewOnce all your references have been upgraded.  You may still see errors in your build templates that say something like Type ‘IBuildDetail’ is not defined.  Turns out the culprit is in the build templates, where there are new references inserted, but because the existing version references are still in there, it causes confusion.  To fix this, I suggest doing so manually, which involves opening up your build templates in code mode.

Simply right-click on your build template file, and choose “View code”.  This opens it up in XAML editor.  As you can see below, there is a reference to Microsoft.TeamFoundation.Build.Client for what seems like version and version  We need to make the version 11 entry fully qualified.

So we go from this:

BuildTemplateXAMLBeforeTo this:


I removed the duplicate reference entries, and fully qualified the newer version.  Do this for any and all TFS references, and your errors should disappear.  Hope this has been helpful.

[UPDATE – 08/29/2013]

After checking in all my changes, I kept getting the below error on my build servers causing my controllers and agents not to start up properly.

BuildWorkflowErrorTurns out TFS didn’t like the specific version on the Microsoft.TeamFoundation.Build.Workflow assembly.  I simply had to remove the specific version notation in my build template code, and let TFS figure out the right version to use.

From this:

xmlns:mtbw="clr-namespace:Microsoft.TeamFoundation.Build.Workflow;assembly=Microsoft.TeamFoundation.Build.Workflow, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
xmlns:mtbwa="clr-namespace:Microsoft.TeamFoundation.Build.Workflow.Activities;assembly=Microsoft.TeamFoundation.Build.Workflow, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

To this:

Tagged , ,

C# Parallel Programming – Increment variable safely across multiple threads

On one of my recent projects, I utilized a bit of parallel programming via the C# Parallel.ForEach construct.  Within the foreach loop, I needed to log what current step in the process I was on, like so Step 1 of n.  So this means we need some sort of variable (let’s call it “x”) that can be incremented to indicate the step number.

Now, we could simply try to increment the variable (as seen below), however, the problem here is that you can have two threads operating concurrently on separate processors, but accessing the same variable.  This may cause  process on thread 1 to increment variable “x” from 0 to 1, but because the process is non atomic (other actions can be performed on the value at the same time), process on thread 2 can at the same time access the value of variable “x”, but still read the value as 0 as it hasn’t been saved yet.

int index = 0;
Parallel.ForEach(databaseNameList, (dbName) =>
var currIndex = index++;
Log(String.Format("Step {0} of {1}", currIndex, databasenameList.Count));

To get around this, we’ll need something that can safely change the value of a shared variable from multiple threads.  This can be accomplished using the lock statement, and you can find an example here.  However, for simpler and faster code, we will utilize the C# Interlocked class.  The Interlocked class has numerous members we can call, but in our case we are particularly interested in the Increment method.  What makes it great is that it performs the increment task in one atomic (meaning no other action can be performed on the value at the same time) operation.  So instead of the above piece of code, it changes slightly to the below code sample.

int index = 0;
Parallel.ForEach(databaseNameList, (dbName) =>
var currIndex = Interlocked.Increment(ref index);
Log(String.Format("Step {0} of {1}", currIndex, databasenameList.Count));

This is a post I’ve held on to and wanted to post for a long while now, so I know it may not be new information, but still hope this little tidbit is useful to someone else.

Tagged , , ,

WinRT: FrameState _PageKey Error

While working on my latest Windows store app, I ran across an issue while performing some navigation between pages.  See the error screenshot below.


You need to make sure that the page being navigated to is calling base.OnNavigatedTo in their OnNavigatedTo methods.  This is because that is where the page key is set up, which is required for when you’re navigating away from a page to save its state.


Tagged , , , ,

WinRT: Unable to activate windows store app

I recently came across this error while building my latest Windows Store app, and found it to be extremely frustrating to say the least.  So I thought I’ll post what I did to resolve it.


After several attempts to resolve the problem, some of which included acquiring a new developer license (via the Project -> Store menu in Visual Studio), restarting Visual Studio, and even restarting the machine.  All to no avail.

Finally, I decided to “pretend” I had just created this project, so I went to the BIN and OBJ folders of the project and deleted EVERYTHING under those folders.  And BINGO, it started working again.

I’m sure some folks have already come across this and have been able to resolve it, but I hope this helps the folks who might just be starting out with Windows 8 development

Tagged , , ,
%d bloggers like this: