But it works on my PC!

The random thoughts of Richard Fennell on technology and software development

Fix for problem faking two SPLists in a single unit test with Typemock Isolator has been released

A blogged a while ago about a problem faking multiple SPList with Typemock Isolator in a single test. With the release of Typemock Isolator you no longer have to use the workaround I documented.

You can now use the code if the originally planned, and it works as expected

   1: public partial class TestPage : System.Web.UI.Page
2: {
3: public TestPage()
4: {
5:  var fakeWeb = Isolate.Fake.Instance<SPWeb>();

7: Isolate.WhenCalled(() => SPControl.GetContextWeb(null)).WillReturn(fakeWeb);
9: // return value for 1st call
10: Isolate.WhenCalled(() => fakeWeb.Lists["Centre Locations"].Items).WillReturnCollectionValuesOf(CreateCentreList());
11: // return value for all other calls
12: Isolate.WhenCalled(() => fakeWeb.Lists["Map Zoom Areas"].Items).WillReturnCollectionValuesOf(CreateZoomAreaList());
13: }
15: private static List<SPListItem> CreateZoomAreaList()
16: {
17: var fakeZoomAreas = new List<SPListItem>();
18: fakeZoomAreas.Add(CreateZoomAreaSPListItem("London", 51.49275, -0.137722222, 2, 14));
19: return fakeZoomAreas;
20: }
22: private static List<SPListItem> CreateCentreList()
23: {
24: var fakeSites = new List<SPListItem>();
25: fakeSites.Add(CreateCentreSPListItem("Aberdeen ", "1 The Road, Aberdeen ", "Aberdeen@test.com", "www.Aberdeen.test.com", "1111", "2222", 57.13994444, -2.113333333));
26: fakeSites.Add(CreateCentreSPListItem("Altrincham ", "1 The Road, Altrincham ", "Altrincham@test.com", "www.Altrincham.test.com", "3333", "4444", 53.38977778, -2.349916667));
27: return fakeSites;
28: }
30: private static SPListItem CreateCentreSPListItem(string title, string address, string email, string url, string telephone, string fax, double lat, double lng)
31: {
32: var fakeItem = Isolate.Fake.Instance<SPListItem>();
33: Isolate.WhenCalled(() => fakeItem["Title"]).WillReturn(title);
34: Isolate.WhenCalled(() => fakeItem["Address"]).WillReturn(address);
35: Isolate.WhenCalled(() => fakeItem["Email Address"]).WillReturn(email);
36: Isolate.WhenCalled(() => fakeItem["Site URL"]).WillReturn(url);
37: Isolate.WhenCalled(() => fakeItem["Telephone"]).WillReturn(telephone);
38: Isolate.WhenCalled(() => fakeItem["Fax"]).WillReturn(fax);
39: Isolate.WhenCalled(() => fakeItem["Latitude"]).WillReturn(lat.ToString());
40: Isolate.WhenCalled(() => fakeItem["Longitude"]).WillReturn(lng.ToString());
41: return fakeItem;
42: }
44: private static SPListItem CreateZoomAreaSPListItem(string areaName, double lat, double lng, double radius, int zoom)
45: {
46: var fakeItem = Isolate.Fake.Instance<SPListItem>();
47: Isolate.WhenCalled(() => fakeItem["Title"]).WillReturn(areaName);
48: Isolate.WhenCalled(() => fakeItem["Latitude"]).WillReturn(lat.ToString());
49: Isolate.WhenCalled(() => fakeItem["Longitude"]).WillReturn(lng.ToString());
50: Isolate.WhenCalled(() => fakeItem["Radius"]).WillReturn(radius.ToString());
51: Isolate.WhenCalled(() => fakeItem["Zoom"]).WillReturn(zoom.ToString());
52: return fakeItem;
53: }
55: }

A check of the returned values shows

  • web.Lists["Centre Locations"].Items.Count returns 2
  • web.Lists["Map Zoom Areas"].Items.Count) returns 1

Installing the TEE11 Beta as an upgrade to the plug-in in Eclipse

The big news today is is that Microsoft released the VS11 Beta, part of which is Team Explorer Everywhere (TEE). (Oh they also release something called Windows 8 too – whatever that is)

Whilst upgrading my TEE instance in Eclipse (Indigo) I hit the same gotcha as I had when I originally installed TEE (in Eclipse is in your ‘c:\programs files’). On Windows, if UAC is enabled you have to run Eclipse as administrator to do the plug-in else you get the error message.


As soon as you start Eclipse as administrator the upgrade works perfectly, you can then restart Eclipse as normal and all is OK

(Not) Using a Huawei E585 MIFI in the USA

I have an unlocked Hauwei E585 MIFI that I use around europe, avoiding roaming charges for my UK mobile contract. I buy a local pay as you go SIM for the appropriate country and off I go.

I thought I would try the same here in the USA, where I am for the MVP Summit. I bought a T-Mobile data SIM, but it did not work so well.

Basically the issue is one of aerials it seems. The E585 does not have the aerials it needs to connect for data in the USA, best it can do is a 2G connection, and even this seems to have issues, as mentioned in this post, that you need a phone SIM and not a data SIM. The bottom line seems to be the E585 is 2100MHz/900MHz UMTS only, AT&T are 850Mhz UMTS, T-Mobile will work on EDGE (2G) only. Verizon is CDMA. So it just just not going to work.

So next we tried it in other devices

  • In a LG E900 Windows Phone 7 it worked fine as a MIFI, but again only 2G/Edge so a bit sloooow, OK for email, but that was all.
  • Next it was a Samsung Windows 8 table form the Build conference, this was better, seemed to be 3G speeds (the icons did not mention the network type), but could not share its network connection

So the top tip? I think I need a US Mifi

You don’t need to keep that old TFS server to support older versions of Visual Studio

I have recently spoken to a number of people who were under the impression that older versions of Visual Studio could not connect to TFS2010. This is not the case. So for example you do not need to keep a TFS2005 running for your VS2005 clients.

Why you might ask does this question even come up? VS2010 can build any .NET 2.0 –> 4.0 project so why not upgrade all your projects to VS2010? The answer is that products such as Biztalk and SQL Business Intelligence use older versions of the Visual Studio Shell e.g. so for SQL 2008 BI you are using in effect VS/Team Explorer 2008. Though it must be said this issue is getting better currently a BI developer still ends up having to use VS 2008 (until SSDT arrives with SQL 2012)

Also some companies may just have a policy to stay on a version of VS for their own reasons.

Either way this is not a barrier to using TFS 2010. The key to getting these older versions of Visual Studio to talk to TFS2010 is only a matter of applying the correct patch sets, so for

All the products can be installed side by side.

Another point to note is that if you are using any of the TFS 2010 PowerTools and want the same features in old versions of Team Explorer you must also install the 2005 and/or 2008 PowerTools versions. Even if the 2010 PowerTools are installed, they will not be found by the 2005 or 2008 clients. The most common time you see this issue is when using check in policies.

For those of you working with VS2003 or VB6 all is not lost, you too can use TFS 2010, you just need Team explorer 2010 installed and the MSSCCI  provider

Hope this post clears up a bit of confusion.

Filtering in MDX Calculated Members

BI development is not something I do that often, but from time to time you need to develop a custom report in TFS. I recently had to battle a MDX problem that someone who does more BI development I am sure why have had no issue with; but as with most of these blog posts (or my long term memory as I think of it) I thought it worth a post in case it helps anyone else

What I was trying to do was produce a table, as shown below, that would allow me to report for a project on the total estimated time in the requirements work items (an estimate made in the requirements planning phase of the project), the total original estimate in the tasks work items (the estimate made by the developers during iteration planning) and compare both with the actual completed time from the task work items.

Project Estimated Effort (from Requirements) Estimated Effort (from Task) Actual Effort (from Tasks)
Proj A 10 11 12
Proj B 15 14 21
Proj C 23 20 24
Proj D 9 10 10


The problem is that in the TFS warehouse both the requirement and task work item estimate in stored in the


measure. In the MDX query I needed to add a pair of calculated measures that would filter for the two work item type.

This is where I stumbled, should I use IIF() or FILTER(). So I tried both. However, working in Report Builder 3 neither seemed to work. I seemed to end up with either an empty column or not filtering at all and showing the sum of all the work items estimates irrespective of the filter.

The first tip is stop work in Report Builder, this is great for making the report look good, but not the best for resolving MDX issues. Use the query tool within SQL Management Studio. As soon as I did this I saw some of my efforts were returning #Err. This explained my empty columns, Report Builder seemed to just swallow the #Err and give me an empty column.

A a bit more digging I found the form that did what I needed, and ended up with the following form for the MDX in the calculated measures

MEMBER [Measures].[EstimatedWorkForTasks] AS '([Measures].[Microsoft_VSTS_Scheduling_OriginalEstimate], [Work Item].[System_WorkItemType].[Task])'

By editing the MDX in SQL Management Studio it was fair quicker to develop and debug


Once I was happy with the MDX, I could cut and pasted it back into Report Builder and fix the layout of the report. And all without using either IIF() or FILTER().

Have you tried switching it on and off again? Go on be aggressive!

We have been building ‘standard’ environments for our TFS Lab Management system. Environments that can be used for most of the projects we are involved in without too much extra setup e.g. a small domain controller VM and a Server VM with SQL and SharePoint. These environments have a series of snapshots so it can be used in a number of ways e.g if we just want SQL and IIS we just go back to a snapshot prior to SharePoint being installed.

When trying to deploy one of these environments we saw a couple issues.


First we got the error that there was not a suitable host with enough capacity to host the environment (remember all the VMs in a network isolated environment need to be on the same Hyper-V host). This can be a bit of a red herring as with dynamic memory and other new Hyper-V features there is often the capacity there (see Tiago’s post on this for more details). The fix here was to set TFS to allow aggressive deployment using the command

C:\Program Files\Microsoft Team Foundation Server 2010\Tools>tfsconfig lab /hostgroup /collectionName:myTpc  ​/labenvironmentplacementpolicy:aggressive /edit /Name:"My hosts group"

Initial Startup

The next problem I saw was that when the new environment was deployed it did not started cleanly. The first time an environment is started it seems to take longer than subsequent starts (assume there is some initial configuration done). Basically in this case network isolation did not start correctly, hence build and testing capabilities also failed.

The fix was simple, shut down the environment and start it again. The tried and trusted IT answer to all problems. This time it started fine, and was faster to start.

Now I have not see this issue every time I deploy. When I deployed the same environment again and it worked perfectly first time. I suspect it was really a capacity issue on the underlying Hyper-V server causing some delay, but I am running in aggressive mode so I should expect this.

TF266026 error when a workflow will not start in a lab environment

A common cause of the TF266026 error is because when the build agent tries to start (it is the build agent that runs the workflows in Lab Management) it cannot access the custom assemblies folder as defined for its parent build controller. Obviously this problem only occurs if you have  set a custom assemblies path for parent build controller.


The reason for the error is because the agent is running as the Lab Management service account, in my case tfs2010lab, as defined for the TPC in the TFS Administration Console. This account by default has no rights to the source folder assigned for the custom assemblies. This is not usually an issue until it needs to access source control to load custom assemblies (which actually it probably does not ever use as it is not building code!).


As soon as this service account is granted access  to this folder, by making it a  reader, contributor or builder on the team project, the problem goes away.

‘Showing a modal dialog box or form when the application is not running in UserInteractive mode’ error upgraded to TFS build extensions

Whilst upgrading a TFS 2010 build today to the new 1.2 release of the Community TFS Build Extensions we hit an issue. All seemed to go OK until the build tried to use the StyleCop activity, which failed with the error

Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.

After a bit of pointless fiddling we decided the only option was to set the build service in question to run interactively (set on the build service properties in TFS administration console on the build box). Once this was done the following dialog popped up


On checking the assemblies copied into the CustomAssemblies folder referenced by the build controller we found we had an older version of this file (from the previous release of the build extensions).

Once we replaced this file we got a bit further, we did not get a dialog, but the build failed with the error in the log

Error: Could not load file or assembly 'StyleCop, Version=, Culture=neutral, PublicKeyToken=f904653c63bc2738' or one of its dependencies. The system cannot find the file specified.. Stack Trace:    at TfsBuildExtensions.Activities.CodeQuality.StyleCop.Scan()    at TfsBuildExtensions.Activities.CodeQuality.StyleCop.InternalExecute() in D:\Projects\teambuild2010contrib\CustomActivities\VS2010\MAIN\Source\Activities.StyleCop\Stylecop.cs:line 134    at TfsBuildExtensions.Activities.BaseCodeActivity.Execute(CodeActivityContext context) in D:\Projects\teambuild2010contrib\CustomActivities\VS2010\MAIN\Source\Common\BaseCodeActivity.cs:line 67.

The issue was we had not upgraded the StyleCop assemblies in the CustomAssemblies folder to match the ones the release of the build extensions was built against (it needed 4.6.30, note not the latest 4.7.x.x.). So we changed these files to the release and the build worked

Interestingly note that the file names have changed from the 4.4.x.x. to 4.6.x.x release of StyleCop from Microsoft.StyleCop.*.dll to just StyleCop.*.dll, so make sure you delete the old files in the CustomActivities folder to avoid confusion.


To the top tip here is to make sure you update all of the assemblies involved in your build to avoid dependency issues.

TF260073 incompatible architecture error when trying to deploy an environment in Lab Manager

I got a TF260073, incompatible architecture error when trying to deploy a new virtual lab environment using a newly created VM and template. I found the fix in a forum post.

The issue was that when I had build the VMs, I had installed the Lab Management agents using a VMprep DVD ISO and mounted it using ‘share image instead of copying it’ option. This as the name implies means the ISO is mount from a share not copied to the server running the VM, this save time and disk resources. When I had stored my VM into the SCVMM Library I had left this option selected i.e the VMPrep.iso mounted. All I had to do to fix this issue was open the settings of the VM stored in the SCVMM Library and dismount the ISO, as shown below


Interestingly the other VM I was using in my environment was stored as template and did not suffer this problem. When creating the template I was warning that it could not be created if an ISO was mounted in this manner. So the fact I had a problem with my VM image should not have been a surprise.

Getting a ‘File Download’ dialog when trying to view TFS build report in Eclipse 3.7 with TEE

When using TEE in Eclipse 3.7 on Ubuntu 11.10 there is a problem trying to view a TFS build report. If you click on the report in the Build Explorer you would expect a new tab to open and the report be shown. This is what you see in Eclipse on Windows and on older versions of Eclipse on Linux. However on Ubuntu 11.10 with Eclipse 3.7 you get a File Download dialog.


I understand from Microsoft this is a known issue, thanks again to the team for helping get to the bottom of this.

The problem is due to how Eclipse manages its internal web browser. Until version 3.7 it used the Mozilla stack (which is still the stack used internally by TEE for all its calls), but with Eclipse 3.7 on Linux it now uses WebKit as the stack to open request URL such as the build report. For some reason this is causing the dialog to be show.

There are two workaround:

Set Eclipse to use an external browser

In Eclipse –> Windows –> Preference, select use external browser



When you now click on the build details an external browser is launched showing the results you would expect.



Switch Eclipse back to using Mozilla as its default

You can switch Eclipse back to using mozilla as its default. In your eclipse.ini set


Once this is done Eclipse should behave as expected, opening a tab to show the build report within Eclipse.