But it works on my PC!

The random thoughts of Richard Fennell on technology and software development

A call for speaker at next month Agile Yorkshire meeting

Next months Agile Yorkshire meeting (10th Feb) is an open floor meeting - any subject, any format, 10 minute maximum.

If you fancy doing something in one of the 10 minute slots - whether it is a presentation, a demonstration, a discussion around a problem area - then visit

http://www.agileyorkshire.org/event-announcements/10Feb2010 to register your idea.

Presentations can be marked as provisional if you like the idea but are unsure until later whether you will be ready, available, etc.

Empty page being show for Silverlight application running out of browser

Whilst preparing demo’s for our design event next week I hit a problem with the out of browser experience in Silverlight 3. I had decided to add the out of browser settings to our 2009 Christmas Card Silverlight application. To do this all you need to do is check a box on the project settings


I ran the application in the browser and all was OK, I right clicked to installed it to the desktop and it ran OK but I got an empty white screen


Turns out the problem was due to a trick we had pulled in the page load. The comic page is a bit long, we had found that of we set the SIlverlight control in the browser page to the comic height the loading spinner could often appear off the bottom of the browser window (especially if the window was not maximised). To address this we set the height of the Silverlight Control small in the containing web page, then at the end of the loading reset it the required height. The fact we were trying to access an HTML Control was the problem, when you are out of the browser there is no HTML page to access.

The solution was single, wrapper the call in conditional test

 if (Application.Current.IsRunningOutOfBrowser == false)
      // resize to the correct size, we keep the height small during the load so the loading spinner is easy to see
      // remember this only works if in a browser
      HtmlPage.Document.GetElementById("silverlightControlHost").SetStyleAttribute("height", "930px");

One this change was made the application worked fine both inside and outside the browser


So you want to demo VS2010 Lab Manager…….

I recently decided to build a demo system for VS2010 Lab Manager. This was for a number of reasons, not least I just wanted to have a proper play with it, but also that I was hoping to do a session on Microsoft Test and Lab Manager at DDD8 (as it turns out my session did not get voted for, maybe better luck for DDS, you can still vote for that conference’s sessions).

Anyway if any of you have looked at the Lab Manager side of MTLM you will know that getting it going is no quick task. Firstly I cannot recommend highly enough the Lab Management Teams’ blog posts ‘Getting started with Lab Management’ Parts 1, 2 ,3 and 4. This type of walkthrough post is a great way to move into a new complex product such as this. It provides the framework to get you going, it doesn’t fix all your problems but gives you a map to follow into the main documentation or other blog posts.

The architecture I was trying to build was as below. My hardware was a Shuttle PC as this was all I could find in the office that could take 8Gb of memory, the bare minimum for this setup. Not as convenient as a laptop for demos, but I was not going to bankrupt myself getting an 8Gb laptop!


As I wanted my system to be mobile, it needed to be it’s own domain (demo.com). This was my main problem during the install. MTLM assumes the host server and all the VMs are in the same domain, but that the domain controller (DC) is on some other device on the domain. I installed the DC on the host server; this meant I had to do the following to get it all to work (I should say I did all of these to get my system running, but they may not all be essential, but they are all sensible practice so probably worth doing)

  • Run the VMM Host as a user other than the default of Local System (this is an option set during the installation). The default Local System user has reduced rights on a domain controller, and so is not able to do all that it needs to. I create a new domain account (demo\VMMserver) and used this as the service account for the VMM.
  • The ‘Getting Started’ blog posts suggest a basic install of TFS, this just installs source control, work item tracking and build services using a SQL Express instance. This is fine, but this mode defaults to using the Network Service account to run the TFS web services. This has the same potential issues as the Local System account on the DC, so I swapped this to use a domain account (demo\TFSservice) using the TFS Administration console. 
  • AND THIS IS THE WIERD ONE AND I SUSPECT THE MOST IMPORTANT. As I was using the host system as a DNS and DHCP the VMs needed to be connected to the physical LAN of the host machine to make use of these services. However as I did not want them to pickup my office’s DHCP service I left the physical server’s Ethernet port unplugged. This meant that when I tried to create a new lab environment I got a TF259115 error. Plugging in a standalone Ethernet hub (connected to nothing else) fixed this problem. I am told this is because part of the LAN stack on the physical host is disabled due to the lack of a physical Ethernet link, even though the DNS and DHCP services were unaffected. The other option would have been to run the DNS, DHCP etc on Hyper-V VM(s).
  • When configuring the virtual lab in TFS Administration console the ‘Network Location’ was blank. If you ignore this missing Network location or manually enter it you get a TF259210 error when you verify the settings in TFS Administration. This is a known problem in SCVMM and was fixed by overriding the discovered network and entering demo.com.

So I now had a working configuration, but when I try to import my prepared test VM into Lab Center, I got an “Import failed, the specified owner is not a valid Active Directory Domain Services account, Specify a valid  Active Directory Domain Services account and try again” error. If I check the SCVMM jobs logs (in SCVMM Admin console) I saw this was an Error 813 in the ‘create hardware setup’ step. However, the account the job was running as was a domain user, as was the service account the host was running on (after I had made the changes detailed above) as I was confused.

This turns out to be a user too stupid error; I was logged in as the TFS servers local administrator (tfs2010\administrator) not the domain one (demo\administrator), or actually any domain account with VMM administrator rights. Once I logged in on the TFS server (where I was running MTLM) as a domain account all was OK. Actually I suspect moving to the VMMService and TFSService accounts was not vital, but did not harm.

I could now create my virtual test environment and actually start to create Team Builds that make use of my test lab environment. Also I think having worked though these problems I have a better understanding of how all the various parts underpinning MTLM hang together, a vital piece of knowledge if you intend to make real use of these tools.

Oh and thanks to everyone who helped me when I got stuck

The uptake of Agile and Alt.Net practices in places a bit away from the major development hotspots

Last week I got into an interesting discussion via email with Nieve a developer from Lille, France.The chat was on the uptake of Agile and Alt.Net practices in places a bit away from the major development hotspots. We both thought it could make an interesting post so, here goes, starting with Nieve’s first post…..

Hello there,I've stumbled upon your blog while googling for the terms alt.net yorkshire.I'm a .NET developer working in Paris and living in the north of France (Lille area). Now, the reason I'm writing is that we're having an alt.net lunch next month, and I would like to talk a bit about the differences between the (alt).net communities in france and england. Now since I did my studies in Leeds, the fact that yorkshire and la région du nord are (surprise surprise) in the north (plus a shared history of mines) brought me to google for alt.net and yorkshire.Over here in Lille/the north of France the situation is rather grim. job offers that entail agile practices and or tools in .NET environment are as rare as an eclipse, managers and developers alike are literally afraid of any framework/tool that isn't microsoft yet somehow miraculously written in a .net language. I suppose you get the picture. I was wondering if you would mind sharing with me (and/or others, on your blog) your thoughts on the situation in yorkshire.

My reply

I don't know if you have heard of Ian Cooper, he was one of the organisers of the ALT.NET events in the UK. Well he just posted on his blog on a subject very close to your question http://codebetter.com/blogs/ian_cooper/archive/2010/01/19/whither-alt-net.aspx

In my opinion there has not been a drop of in interest over the tools and practices of ALT.NET but it has lost it’s label a bit. Ian is right the main people pushing it have moved more towards Twitter etc. which has reduced visibility if you don't follow them.

Local groups are still on the go. I myself attend Agile Yorkshire http://www.agileyorkshire.org/ which is a group driven by development process (being JAVA and .NET) but did help organise the ALT.NET in the North event last year. We hope to run something this year, but we doubt it will be under the ALT.NET banner as it was felt this alienated JAVA members

As to who is using the tools, no as many as I would hope. But you find them in surprising places. I found out that a dev teams in the NHS (usually known to be very bureaucratic and fixed management process) are using Kanban, nHibernate etc. and finding them useful. Getting adoption is all down to someone showing there is an advantage, the problem is so few people in our industry care about improving their skills, it all comes back as Ian said to the software craftsmanship movement

Nieve again

First of all let me begin by saying I only wish I could tell you how much I am thankful. Reading Ian's post was a something of an epiphany moment :) At some points he brought it so close to home that I had to stop and think 'hold on, is he just talking about software development or is there a hidden message about the state of France..?' Over here it's not only the IT industry that breeds this sort of position holders that are fine where they are and just won't bother changing anything. I always think of it as 'with all that revolution going on, you don't get any evolution'; the idea is that everyone here are jumping to their feet and straight to the street to cry against whatever change that is offered, that nothing ever gets to change hence no evolution...

To get back to the issue in question, I think one of the things Ian, and for that matter many of the ALT.NET people, tend to forget or simply overlook is the fact that while at some parts of the world people may think the battle was won, or that it's about time to wake up from our comfortable twitter hibernation, in some other parts the battle hasn't even began, which brings me back to my original question. See, you guys up the in England and esp. in the north can be very proud of your community, and not only the alt.net/agile/software development/IT one, but also the local-geographical community. I had to go and look for a job in Paris, which entails a couple of hours on the train each and every day and which is bound to end by leaving Lille (and no wonder I'm considering moving back to yorkshire); Not only developers and managers are afraid of anything that is not microsoft, the actual idea of software craftsmanship is an abnormality in our region. There is a Nord-agile group that works here and have meetings every couple of months and consists of 5 to 7 people, none of them a .net person. And we're talking about a huge region and one of france's 5 biggest cities.

With that in mind, there's also the fact that roughly each and every year a new generation of developers is arriving to the market which makes it even more difficult to those (esp the beginners to senior-juniors) who wants to learn and work on their coding craftsmanship. (I remember I discovered the alt.net manifest only a couple of years ago or so, and soon after I remember reading a post of Ayende saying he's going to give Twitter a shot. Thank god, he's one of those who never stopped blogging.)

As for Paris, things seem to be closer to what Ian said; there are a lot more job offers that ask for a working experience in NH, MVC, NUnit etc', however this feels like the new orthodoxy.

… and me again

So to me this shows that the problem we both see are not just down to us at our company/technology/region/country. Craftsman Developers everywhere tend to sit in small isolated pockets, even in large conurbations, and there is nothing to go but to organise locally where you can, go on go for a beer you know you want to, and to join in the virtual communities to get a bigger world view.

Wow, that sounds like a call to revolution, better go into hiding in case the thought people come round, I know I will just have to think I am not in!

Running Typemock Isolator based tests in TFS 2010 Team Build

Updated 2nd March 2010: Altered the sample arguments see this post for more details

Updated 27th Jan 2010: Gian Maria Ricci, another Team System MVP has done some more work on this problems and posted on how to create a custom activity to address the problem.

I have been looking at getting automated builds running on TFS2010 that make use of Typemock Isolator. This is not as straight forward as you would expect.

The issue is that you have start Isolator’s mocking interceptor before you run any tests that use Typemock (and stop it afterwards). If you are running in the VS IDE this is all done automatically, but is not done as part of an MSBuild Team Build Process by default.

In prior versions of TFS a solution was provide by Typemock in the form a pair of MSBUILD Tasks to start and stop the mocking process which you wired into your team build definition file, something like the example below

<Import Project="C:\Program Files\Typemock\Isolator\4.3\TypeMock.MSBuild.Tasks" />
<Target Name="BeforeTest">
<TypeMockStart LogPath="C:\TypeMockLogs" LogLevel="9" Target="3.5" />
<Target Name="AfterTest">
<TypeMockStop />

The problem with 2010 is that you no longer get this single MSBUILD file to manage the Team Build, it is now a XAML workflow. I know I could use the model for legacy support of the older build process, but where is the fun in that?

Attempt 1 – Adding more MSBuild projects


My first idea was to add a MSBUILD activity just before the MSTEST activity block (and another after to stop the mocking interceptor) and pointed it at a Typemock.Proj file (placed in in a suitable location) and calling the correct target. The proj file is shown below

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <TypeMockLocation> C:\Program Files (x86)\Typemock\Isolator\6.0</TypeMockLocation>

  <Import Project ="$(TypeMockLocation)\TypeMock.MSBuild.Tasks"/>
  <Target Name="StartTypeMock">
    <Message Text="StartTypeMock"/>
  <Target Name="StopTypeMock">
    <Message Text="StopTypeMock"/>

In the build logs I could see the activities ran, and a typemock.log file is created for the MSBuilds (note a problem here that as I use the same proj for both the start and stop build target the log file gets over written, so a good idea is to pass in explicit log file names for each call to MSBUILD). However, even though everything seemed to run OK the test that need Typemock fail with the error

Test method CallTracker.BusinessLogic.Tests.PrintTests.PrintAllCalls_TypeMockedPrinter_2CallsPrinted threw exception:
*** Typemock Isolator is not currently enabled.
To enable do one of the following:
* To run Typemock Isolator as part of an automated process you can:
   - run tests via TMockRunner.exe command line tool
   - use 'TypeMockStart' tasks for MSBuild or NAnt
* To work with Typemock Isolator inside Visual Studio.NET:
        set Tools->Enable Typemock Isolator from within Visual Studio
For more information consult the documentation (see 'Running' topic)

This is exactly the error you expect if you have not started the mocking interceptor.

After a chat with Typemock support I understood the problem. In the TFS 2005/8 model we had a single MSBUILD process running. It compiled the code, ran the tests, it did everything. So if we started mocking interception in this process everything was good and it all worked. Under the 2010 model we have the new XAML based process, this starts a MSBUILD process to do the compile, and in our case another to start mocking, then MSTest to run and finally another MSBUILD to stop mocking. So we have at least four process within the build and the reality is we have only switched on mocking for the duration of the MSBUILD task calling the StartTypemock task.

Attempt 2 – Other task types

I did also look at starting mocking using the INVOKEMETHOD task and by calling the Typemock provided batch files. These all resulted in the same basic problem, mocking was not switched on when MSTest ran.

A solution

The solution is to use the TMockRunner.EXE that is shipped with TypeMock Isolator. This is a wrapper EXE that runs a command line tools passing in the required set of parameters. All the TMockRunner does is, as the name suggests, start and stop the mocking as needed.

To get this to work I removed the MSTest task in the build workflow and replaced it will a InvokeProcess one with the following parameters

FileName: "C:\Program Files (x86)\Typemock\Isolator\6.0\TMockRunner.exe"

"""C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe""  /nologo /testcontainer:""" + String.Format("{0}\Binaries\Testproject.dll", BuildDirectory) + """ /publish:""http://typhoon:8080/tfs/DefaultCollection"" /publishbuild:""" + BuildDetail.Uri.ToString() + """ /teamproject:""" + BuildDetail.TeamProject + """ /platform:""Any CPU"" /flavor:""Debug"" /resultsfile:""" + String.Format("{0}\Binaries\Test.Trx", BuildDirectory) + """  "

"""C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe""  /nologo /testcontainer:""" + String.Format("{0}\Binaries\BusinessLogic.Tests.dll", BuildDirectory) + """ /publish:""http://typhoon:8080/tfs/DefaultCollection"" /publishbuild:""" + BuildDetail.Uri.ToString() + """ /teamproject:""" + BuildDetail.TeamProject + """ /platform:""" + platformConfiguration.Platform + """ /flavor:""" + platformConfiguration.Configuration + """ /resultsfile:""" + String.Format("{0}\Binaries\Test.Trx", BuildDirectory) + """  "

A few things to note on the arguments and settings

  1. The arguments have to appear as a single string, so this is why you have all the double quotes escaping
  2. The Resultsfile is dumped into the binaries directory as this is cleaned out on each build. It has to go in an existing directory (we have no TestResults by default, of course we could create one, but why go to the effort?). This is a simple solution as the MSTest still seems to fail if the Test.TRX file already exists, Note I did try to use the /resultsfileroot parameter (which is used by default by the 2010 MSTest task) but this is not support via the command line.
  3. I would like to pickup the publish URL, platform and flavor automatically, I need to dig port into the TFS API to find these values at build time.
  4. I have not wired the MSTest output back into the main log, so it is hard to see what has happened without just looking for the creation of the TRX file.
  5. Watch out for DCOM activation errors. There is a good chance the user you are running the build process as does not have the right to run anything else. If your InvokeProcess seems to do nothing check the build PCs error log for DCOM activation errors and either give the build user the correct rights or swap to a user that already has the rights.

Once this was all done I could do my build and the test ran and passed.

The one remaining issues was to set the Test status for the build base done these results, I have no solution to that as yet, but I am still looking

Problems installing TFS Proxy

I recently saw an interesting problem install a TFS proxy (in my case it was on an existing TFS 2005 system using Window Server 2003 for the proxy host, but the problem could be seen on any version f TFS). The installation appeared to go fine, and when a Visual Studio client requested files, via the proxy, files appeared in the cache directory, however the client reported it was not using the proxy.

When I tried to look at the proxy statistics using http://localhost:8080/VersionControl/v1.0/proxystatistics.asmx I was shown a standard IE login dialog, not what expected as I was logged in as the administrator. No credentials were found that could get past this dialog.

I started looking a firewall settings, anti virus port blocker, and local loopback settings, but it turned out the problem was far more fundamental. The IIS6 installation was corrupted. When I dropped test files into the proxy server virtual directory I found I the server could render an HTML page but not an .ASP or ASP.Net ones.

So I removed IIS from server, then put it back and on the problems went away. All I can assume is some IIS/.NET installation/patching order issue. I bet it would not have happened with I had started with Server 2003 R2 with .NET already on it.