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 , ,

Xamarin – User interaction with image views

It’s sometimes the simplest of things I tend to overlook when debugging.

While recently working on one of my company’s mobile apps, I came across an issue which had me stomped for a good 30 minutes before realizing how easy it was to resolve.

Part of the work involved creating custom views in our app to display mobile ads.  UIImageViews to be exact.  This view contains a full screen image, and a close button at the top right of the view to dismiss the ad.  Simple, right!  Well, the problem was no matter what I did, the close button did not respond to any touch events.

As you can see from the code sample below we’ve taken the route of using C# to create some of our views.  Here is what the constructor of the subclassed UIImageView looked like before solving the problem.

public FullPageAdView(float adWidth, float adHeight, Ads ads) : base(new RectangleF(0, 0, adWidth, adHeight))
if (ads == null)
throw new ArgumentException("Mobile Ads are missing");

MobileAds = ads;
closeButton = UIButton.FromType(UIButtonType.Custom);
closeButton.SetImage(UIImage.FromBundle(“RedCloseButton.png”), UIControlState.Normal);
closeButton.SetImage(UIImage.FromBundle(“RedCloseButtonClicked.png”), UIControlState.Selected);
closeButton.TouchUpInside += OnCloseButtonClicked;


We’ve properly registered the TouchUpInside button event and added the button to our custom view.  Should just work right…NOPE!  Turns out many of the controls in UIKit, including UIImageView, do not have touch enabled by default.  It has to be turned on as you can see in the snippet below.

public FullPageAdView(float adWidth, float adHeight, Ads ads) : base(new RectangleF(0, 0, adWidth, adHeight))
if (ads == null)
throw new ArgumentException("Mobile Ads are missing");

MobileAds = ads;
closeButton = UIButton.FromType(UIButtonType.Custom);
closeButton.SetImage(UIImage.FromBundle(“RedCloseButton.png”), UIControlState.Normal);
closeButton.SetImage(UIImage.FromBundle(“RedCloseButtonClicked.png”), UIControlState.Selected);
closeButton.TouchUpInside += OnCloseButtonClicked;
this.UserInteractionEnabled = true;

If you are using Xcode to create your image view, here is what the option looks like (borrowed image from here).


And there you have it. Simple solution to a simple problem.

I hope this saves someone else the hassle and time I spent in resolving this issue.

Happy Xamarin trails!

Tagged , , , , ,

Xamarin App Rejected – Position Independent Executable

Recently, my Xamarin mobile app was rejected from the App store with the following error.

Non-PIE Binary – The executable ‘’ is not a Position Independent Executable. Please ensure that your build settings are configured to create PIE executables.

Turns out Apple recently introduced an extra step in the build process , which now requires your app to be built as Position Independent Executable (PIE).  Position Independent Executable (PIE) applications can be loaded at a random memory address when run. This has security benefits for your application. iOS 4.3 or later, and OS X 10.7 or later, fully support PIE executables.

Fortunately, Xamarin has also updated their framework to support building applications as PIE.  You can find this update via the Beta Channel, Xamarin iOS 6.3.7 to be exact.  So any native executable is now built as PIE by default.

I hope anyone who runs into the PIE issue finds this helpful.

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 , , ,

Cross-Platform Mobile Development

With a plethora of options for building mobile apps, be it a “build for each platform”, or “build once for all platform” strategy, there is a lot of argument around what path is the better one. The main points discussed are whether the Native or Hybrid approach is more appropriate. My response to a lot of these discussions has and, I think, always will be IT DEPENDS.

Going Native – Programming in the native language of the platform, I think, will always be the preference. Especially for applications that require the innermost workings of the platform. Apple iOS has Objective-C, Android has Java, and Windows Phone has .NET. Well, I guess we can’t forget about the Blackberry platform which primarily is built using Java.

Going Cross-Platform (Hybrid) – Today, there are more hybrid solutions to mobile development than one can keep up with. I liken the hybrid route to traveling to a foreign country, say France, where French is the primary language (like…obvious), but since I don’t speak the language fluently, I use a mixture of English, and hand gestures. It works, and will probably help me communicate decently, but it only goes so far, and can only accomplish so much. At some point, I’ll need to speak French. Some big players in this field include Sencha, Phonegap, & JQuery Mobile, just to name a few. I have personally played around with Sencha the most, and while it is an incredible platform, I found it to have somewhat of a steep learning curve, but that’s just me. Again, I just don’t speak “French” that well.

However, imagine if you had a French translator. Someone who can bridge that gap between you, and the oh so lovely French folks, without any loss in the quality of the communication. In fact, this translator not only spoke French, but could speak about every other language known to man, well, maybe except one (*cough* Blackberry *cough*). You could effectively use your translator anywhere in the world.

In the hybrid/cross-platform mobile development realm, I consider this “translator” to be Xamarin.  As it says on their website,

Xamarin is unique in this space by offering a single language – C#, class library, and runtime that works across all three mobile platforms of iOS, Android, and Windows Phone (Windows Phone’s indigenous language is already C#), while still compiling native (non-interpreted) applications that are performant enough even for demanding games.

It is a very powerful platform to say the least.  A game changer if you ask me.  Xamarin not only combines the powerful of all 3 platforms, but it adds its own features on top.  Some of which include:

Bindings for the Indigenous SDK: Xamarin provides strongly-typed binding for nearly the whole underlying platform SDKs in both iOS and Android.  Some advantages to this include type checking during development, and compilation.

Invoking native libraries – This gives you the power to use existing iOS and Android libraries written in Objective-C, Java or C/C++.  Xamarin just released a tool, Objective Sharpie, which takes much of the manual work of translating Objective C APIs into binding definitions that are consumed by Xamarin’s binding tools.

Modern Language features – Xamarin applications are written in C#, allowing developers to take advantage of strengths such as Dynamic Language features, and Functional Constructs such as LINQ, Lambdas, Generics, etc.  Many of these features are significant improvements over Objective-C and Java.

Use of Base Class Library (BCL) – Xamarin utilizes the .NET BCL, which is a collection of many classes that provide a comprehensive set of features like XML, Database, Serialization, Networking, and IO support, to name a few.

Amazing Development Environment – Formerly called MonoDevelop, Xamarin has revolutionized their Integrated Development Environment (IDE), now called Xamarin Studio.  It also provides deep integration with the Visual Studio IDE, allowing the .NET developer’s favorite IDE to be used for development as well.

Mobile Cross-platform support – With the support coverage across all three platforms (iOS, Android, Windows Phone) provided by Xamarin, developers can expect to share up to 90% of their code.  During my last project, we estimated a code sharing rate of about 80%, saving a ton of time and effort in development and time to market.  We were able to release two apps for both the iPhone and iPad, in 100 days (from Concept to Store).

Over the next few weeks/months, I’ll be sharing many of my experiences using this incredible framework, and engage with the dev community, while learning from you all as well.

Happy Xamarin trails!

Tagged , , , , , , ,

Update Xamarin assemblies in 3rd party dll’s

Since the birth of Xamarin.iOS 6.0 (formerly MonoTouch), many of the platform assemblies are now been signed. Some of which include the monotouch.dll, MonoTouch.Dialog-1.dll and OpenTK-1.0.dll.

In many of our projects, we use 3rd party dlls that have a reference to these now signed Xamarin assemblies.  When you upgrade to Xamarin.iOS 6.0, it causes annoying assembly version build errors.  So what can one do?  Wait for the 3rd party vendors to update their assemblies?  I think not.

In comes the Xamarin.iOS reference updater.  Thanks to Rolf Bjarne Kvinge, a Xamarin-ian no less, you won’t have to wait on those pesky 3rd party vendors to update their Xamarin assembly references.  The reference updater project provides a simple Xamarin solution, which you open and build using Xamarin Studio.  After building the solution, you will need to open a terminal window, navigate to the project directory where iOSRefUpdater.exe is located and execute the following command to convert the third-party assembly in place.

mono iOSRefUpdater.exe /path/to/third/party/assembly.dll

One other nice feature of this utility is that it also creates a backup of the assembly being converted in-place.

Tagged ,

Opening a TFS 2010 build process template in Visual Studio 2012

I recently came across a scenario when trying to edit TFS2010 build process templates within VS 2012, and thought I would share some lessons learned.

When you open up a tfs 2010 build process template within VS 2012, you may get the following error (see below). In my case, I have all my templates linked into a .NET project. Whenever I open the same template outside the project, things seem to be ok, which led to me to think something about the project was causing my headaches.

Build Settings Error

With this information, my next destination were the project settings.  As you can see, the project currently targets the “.NET Framework 4 Client Profile”, so as soon as I changed this to target “.NET Framework 4.5”, the templates began loading succesfully again.  However, it didn’t end there for me.


There was one more quirk I found after the template had loaded.  As you can see, the template now indicated it has and error on the “Run MSBuild for Project” activity.

Here is the error message: “Compiler error(s) encountered processing expression Microsoft.TeamFoundation.Build.Workflow.BuildVerbosity.Normal.  ‘BuildVerbosity’ is ambiguous in the namespace ‘Microsoft.TeamFoundation.Build.Workflow'”. 

In examining the properties, it clearly shows it didn’t like the object type for the “Verbosity” property.   The Verbosity(BuildVerbosity) property is mapped to one of my custom arguments which I’ve called, well, Verbosity.


All I had to do was go to my argument in the Arguments list.  Once I located my “Verbosity” agrument, I clicked on the Argument type column, which should show you a drop down with several options.  Click on the “Browse for types”, and go to the workspace “Microsoft.TeamFoundation.Build.Workflow []”, then to “Microsoft.TeamFoundation.Build.Workflow”, and then select “BuildVerbosity” type.  This should resolve the error.



NOTE: If you use the IBuildDetail or IBuildAgent variable types, you may need to perform the same above step for their respective namespaces.

[UPDATE – 08/27/2013]

Check out an update (with more relevant and detailed info) to this post here.

Tagged , , , ,

Congress Watch for Windows 8

Last year, as I set out to explore the Windows Store app dev ecosystem, I pondered what my first project would be.  On the Windows Phone platform, my first app was a diary app called Easy Diary, which has done very well (but is in need for some Windows Phone 8 upgrade magic).  It was also a few months before the Presidential elections, so I figured, why not create something that would help folks like you and I keep tabs on what is going on in Washington.  So Congress Watch was born.


Congress Watch is a gateway to detailed information about your elected U.S. Congressional officials. A great way to learn about those who represent you in Congress.
With profile details, news feeds, and videos, become an informed and active citizen between elections and different sessions of Congress.


Basic Information
List of all legislators, including member first and last name, title, and political party affiliation.

Contact Information
Official website link, member contact form, Washington, DC office address, telephone, and fax numbers.

Legislative activity
Included are up-to-date news, and YouTube videos for Congress members. 

Bonus Features
Live tiles for congress members which display current news and allow users to launch directly to the legislator profile page within the app. Search for legislators, and Share with your family and friends.

This app was built using the Open Congress and Sunlight Labs API’s, but is currently not endorsed by either party.


So if you are at all interested in finding out what our folks up in Congress are doing (or not doing), then please check out my app.  Click the image below to download Congress Watch from the Windows Store.

P.S. Version 2 is already in the works and promises to deliver an improved user experience and a more organized wealth of information (along with a few premium features).  Any suggestions/ideas are most welcome.

Congress Watch Promotional

Tagged , , , , , , ,
%d bloggers like this: