But it works on my PC!

The random thoughts of Richard Fennell on technology and software development

More experiences upgrading my Media Center to receive Freeview HD

In my post experiences upgrading my Media Center to receive Freeview HD I said I thought the reason my Windows 7 Media Center was hanging at the "TV signal configuration” step was down to using mixed tuner cards. Well my second PCTV nanoStick T2.arrived yesterday so I was able to try the same process with a pair of identical USB T2 tuners.

Guess what? I got the same problem!

However, being USB devices it mean I could test the tuners on my laptop, a Lenovo W520 (Core i7, 16Gb, Windows 7). So I plugged them both in, they found drivers from the web automatically, I ran Media Center, select setup the TV signal and……. it worked! A few worrying pauses here and there, but it got there in about an hour.

So why did it work on a laptop and not on my Media Center PC?

I considered performance, but it seemed unlikely,the Media Center is aCore2 Duo based system about 3 years old and has had no performance problems to date. So the only difference was that the laptop had never seen a TV Tuner before, the Media Center had.

Unused drivers

So I wondered if the old Hauppauge drivers were causing the problem. Remember in Windows if you removed an adaptor card then the drivers are not removed automatically. If  the driver was automatically added (as opposed to you running a setup.exe) then there is no obvious way to removed the drivers. The way to do it as detailed in this Microsoft Answers post. When you load device manager this way you see the Hauppauge devices and you can uninstall their drivers.

And it makes no difference to the problem.

Media Center Guide Data and Tuner setup

Using task manager I could see that when Media Center TV setup appeared to hang the mcupdate.exe program was running and using a lot of CPU. I had seen this on the Lenovo, but it has passed within 30 seconds or so, on my 3 years old Intel based Media Center PC I would expect it to be a bit slower, but I left it overnight and it did not move on. So it is not just performance.

The mcupdate.exe is the tools that updates the TV guide data for Media Center. It is run on a regular basis and also during the setup. So it seems the issue as far as I can see that

  1. There is corrupt guide data so that it cannot update the channel guide
  2. There is data about a non-existent tuner that locks the process
  3. There is just too much data to update in the time allows (but you would expect leaving it overnight would fix this)
  4. There is an internet problems getting the guide (which I doubt, too much of a coincidence it happens only when I upgrade a tuner)

Simply put I think when the TV setup gets to the point it needs to access this data, it gets into a race condition with the mcupdate.exe process which is trying to update the guide.

The Hack7MC blog post seems to suggest the problem is that the guide data and tuner setup needs to be cleared down and provides a process. post suggest the problem can be addressed by cleared down the data; it provides a process to do this. However I though I would try to avoid this as I did not want really to loose the series recording settings I had if I could avoid it.

So I loaded Media Center and select update guide from the Task menu. This started the mcupdate process and  caused a 50% CPU load, and showed no sign of stopping. Again pointing to a probably one of the issues listed above. So I unloaded Media Center, but mcupdate.exe was still running as was the tool tray notification application. Again I left this a while to no effect. So I used task manager to kill mcupdate and the ectray.exe application.

I had at this point intend to run the process from the Hack7MC post, so stopped all Media Center services, but thought i would give the setup one more try. When I ran the setup TV dsignal I got a message along the lines of ‘guide data corrupt will reload’ and then the setup proceeded exactly as it should have done in the first place. I ended up will all my channels  both HD and non-HD accessible from both tuner, and all my series recording settings intact.

So a success, I am still not clear which step fixed the issue, but I am sure it was down to needing to clear down the guide data and tuner setting fully.

Access denied when running a command with InvokeProcess in a TFS team build

When you are trying to run a command line tool via the InvokeProcess activity in a TFS 2010 Team build you might see the somewhat confusing ‘Access denied’ error. There appears to be no more detail in the log.

I have found that this is usually down to a type on the filename property of the activity.

It should be set to something like

“c:\my tools\tool.exe”

but is actually set to

“c:\my tools”

i.e. it is set to the folder not the filename. An easy mistake to make of cutting and pasting paths in from batch files.

You cannot execute a folder, hence the access denied error. Simple but easy to miss.

No error detail when using VMPrep

When using VMPrep to setup a VM for use in a Lab Management system I got the error cross at the bottom of the dialog

image

Not too much help, usually there is a link to the log file or a message.

If you look in the log file in c:\user\[name]\Appdata\Roaming\LMInstaller.txt you see that the path to the Patches folder is invalid.

This is fixed by editing the VMPrepTool\VMPrepToolLibrary\Applications.XML file and correcting the path (which I had made a typo in)

Using Nuget and TFS Build 2010

At one of our recent events I was asked if I had any experience using Nuget within a TFS 2010 build. At the time I had not, but I thought it worth a look.

For those of you who don’t know Nuget is a package manager that provides a developer with a way to manage assembly references in a project for assemblies that are not within their solution. It is most commonly used to manage external commonly used assemblies such a nHibernate or JQuery but you can also use it manage your own internal shared libraries.

The issue the questioner had was that they had added references via Nuget to a project

image

Their project then contained a packages.config file that listed the Nuget dependencies. This was in the project root with the <project>.csproj file.

<?xml version="1.0" encoding="utf-8"?>
<packages>   <package id="Iesi.Collections" version="3.2.0.4000" />   <package id="NHibernate" version="3.2.0.4000" />
</packages>

This packages.config  is part of the Visual Studio project and so when the project was put under source control so was it.

However, when they created a TFS build to build this solution all seems OK until the build ran, when they got a build error along the lines

Form1.cs (16): The type or namespace name 'NHibernate' could not be found (are you missing a using directive or an assembly reference?)
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets (1490): Could not resolve this reference. Could not locate the assembly "Iesi.Collections". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets (1490): Could not resolve this reference. Could not locate the assembly "NHibernate". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.

Basically the solution builds locally but not on the build box, the assemblies referenced by Nuget are missing. A quick look at the directory structure show why. Nuget stores the assemblies it references in the solution folder, so you end up with

Solution Directory
      Packages – the root of the local cache of assemblies created by Nuget
      Project Directory

If you look in the <project>.csproj  file you will see a hint path pointing back up to this folder structure so that the project builds locally

<Reference Include="NHibernate">
      <HintPath>..\packages\NHibernate.3.2.0.4000\lib\Net35\NHibernate.dll</HintPath>
</Reference>

The problem is that this folder structure is not known to the solution (just to Nuget), so this means when you add the solution to source control this structure is not added, hence the files are not there for the build box to use.

To fix this issue there are two options

  1. Add the folder to source control manually
  2. Make the build process aware of Nuget and allow it to get the files it needs as required.

For now lets just use the first option, which I like as in general in do want to build my projects against a known version of standard assemblies, so putting the assemblies under source control is not an issue for me. It allows me to easily go back to the specific build if I have to.

(A quick search with your search engine of choice will help with the second option, basically using the nuget.exe command line is the core of the solution)

To add the files to source control, I when into Visual Studio > Team Explorer > Source Control and navigated to the correct folder. I then pressed the add files button and added the whole Packages folder. This is where I think my questioner might have gone wrong. When you add the whole folder structure the default is to exclude .DLLs (and .EXEs)

image

If you don’t specifically add these files you will still get the missing references on the build, but could easily be thinking ‘ but I just added them!’, easy mistake to made, I know I did it.

Once ALL the correct files are under source control the build works as expected.

Seeing loads of ‘cannot load load assemblies’ errors when editing a TFS 2010 build process workflow

I have been following the process in the ALM Rangers build guide and in the Community Build Extensions to edit a build process workflow. Now I am sure this process was working until recently on my PC (but we all say that don’t we!), but of late I have found that when the .XAML workflow is loaded into Visual Studio I see loads of warning icons. If I check the list of imported namespaces many of them also have warning icons which if the icons are clicked they say the assembly cannot be found.

image

Now all these errors did not stop the editing process working. What I found was that if I made an edit in the graphical designer for the workflow or edited a property of an activity then my Visual Studio instance locked for about 20 seconds and it was fine (whilst there was loads of disk activity). I also noticed I got no intellisense when setting properties. Not a great position to be in but at least I could make some edits, if only slowly.

Using Process Monitor I could see that Visual Studio was scanning folders for the files when loading the XAML workflow, but not finding them.

The fix is actually simple. In the project that is being used as a container for the workflow being editing, make sure you reference the missing assemblies. These can be found in one of the following folders

  • C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE
  • C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies
  • C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ReferenceAssemblies\v2.0

On my PC most of the assemblies were in the ReferenceAssemblies folder, not the first two, but on checking another PC at my office they were present in the PrivateAssemblies (which VS does scan)

Not sure why this has stopped working, what removed the files from my PrivateAssemblies folder, the only thing I can thing that I did was to install the Dev11 preview, But can’t see how this should have any effect.

Empty groups not being expanded in a combobox for a TFS work item

A common work item type (WIT) edit in TFS is to limit the list of names shown in a combo to the users assigned to the project i.e. the members of the Team Projects Contributors and Project Administrators groups.

This is done by editing the WIT either via your favourite XML editor or the Process Template Editor (part of the power tools). You edit the Allowedvalues for the field you wish to limit such as the Assigned To as shown below,

image

Which gives the following XML behind the scenes (for those using XML editors)

<ListRule filteritems="excludegroups">
  <LISTITEM value="[Project]\Contributors" />
  <LISTITEM value="[Project]\Project Administrators" />
  <LISTITEM value="Unassigned" />
</ListRule>

Notice that Expand Items and Exclude Groups are checked. This means that the first two lines in the list will be expanded to contain the names in the groups, not the group names themselves.

A small gotcha here is that if either of the groups are empty you do see the group name in the combobox list, even with the Exclude Groups checked. Team Explorer does not expand an empty list to be a list with no entries, it show the group name. So you would see in the combo something like

  • [MyProject]\Contributors
  • John
  • Fred
  • Unassigned

where John and Fred as project administrators and the [MyProject]\Contributors group is empty.

This should not be a serious issue as in most cases why would you have a Team Project with no contributors or administrators? However it is conceivable with more complex security models you might see this issue. if so make sure each group in the list has at least one member, again if it does not have any members do you really need it?

Stupid gotchas on a SQL 2008 Reporting Services are why I cannot see the Report Builder Button

There is a good chance if you are using TFS that you will want to create some custom reports. You can write these in Reporting Services via BI Studio or Excel, but I wanted to use Report Builder, but could not see the Report Builder button on this Reporting Services menu

image

The problem was multi-levelled

First I had to give the user access to the Report Builder. This is done using folder property security. I chose to give this right to a user (along with browser rights) from the root of the reporting services site

image

But still no button. Forums and blog posts then talk about changing options on the ‘Site Settings’ menu, the above screenshots shows that this is also missing from the top right.

To get this menu option back, I had to run my browser as administrator and then this option appeared. Turns out that the TFS Setup user I was using  had not been made a Reporting Services site administrator, just a content administrator.

But still this was not enough, I also add to add users as System Users to allow the Reporting Services button to appears. So my final Site Settings > Security options were

image

Once all this was done I got my Report Build button and I could start to write reports.

What to do when your TFS build agent says it is ready, but the icon says it is not

When using TFS2010 It is possible for a build agent to appear to be ready (or so the status label says) but the icon stays in the off state.

image

This is usually due to a couple of broad categories of error, you can find out which by checking the Windows event log.

The build agent cannot communicate with the controller

In the event log you see something like

Service 'Default Agent - win7' had an exception:
Exception Message: There was no endpoint listening at
http://controller.mydomain.co.uk:9191/Build/v3.0/Services/Controller/1 that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details. (type EndpointNotFoundException)

This should not happen too much within a corporate LAN, though it is always worth checking to make sure any PCs firewalls are not blocking the port used by the build service (9191).

However if you are trying to use build agents that are not directly on your LAN/AD (see this lovely clear blog post on how to set up using a non-domain joined build agent) there is a good chance you will not have DNS working as expected. So make sure the controller can resolve the name of the agent and vice versa. For me this meant editing HOST files and checking name resolved with good old PING.

Custom assemblies have un-resolved dependencies

Whilst writing documentation for the community extensions for TFS build I had the this problem. I had the custom assemblies path set for the build controller. This meant when the build agent starts it downloads any custom assemblies from the specified folder. Some the community extensions assume that the build agent has features/application installed such IIS or Visual Studio. I had assumed any missing dependencies would only show up when you tried to use a community activity in a build. However, this is not the case it seems. During the agent load some checks are made. In the event log I saw errors such as

Service 'Default Agent - win7' had an exception:
Exception Message: Problem with loading custom assemblies: Could not load file or assembly 'Microsoft.VisualStudio.Shell, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. (type Exception)

or

Service 'Default Agent - win7' had an exception:
Exception Message: Problem with loading custom assemblies: Could not load file or assembly 'Microsoft.Web.Administration, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. (type Exception)

To resolve these issues I installed the features and application on the agent needed by the build extensions. The other option would be remove the custom extension assemblies that had the dependencies, assuming you did not need them.

So hopefully this post should give you a pointer on fixing strange ‘has it started or not’ states that the build agent can get into

Bitlocker keeps asking for my recovery key after a change in my disk’s MBR

My development laptop is bitlocker’ed, and yours should be too. It provides a great and non-invasive way (assuming you have a TPM chip) to protect you and your clients data on a machine that is far to easy to steal or loose. However, whilst fiddling with Windows 8 I did trip myself up.

I have my PC setup for a boot to Windows 7 from a bitlocker’ed drive C with a non bitlocker’d drive D used to boot to Windows 2008 for demos (and hence no production data). To try out Windows 8 I added a new boot device, a boot from VHD partition. This edited the PC’s master boot record (MBR) and bitlocker did not like it. It thought the PC had a root kit or something similar to prompted me to enter a my bitlocker recovery key (which is 48 characters long) when I tried to boot to Windows 7. However, once this is done my bitlocker’ed Windows 7 partition worked find, but on each reboot I had to type the key in, bit of  pain. Removing the new VHD boot entry did not help, the MBR has still be edited, so bitlocker complained

The solution was actually easy, but took me a while to find as it does not seem to be clear in any documentation or via a search.

When the WIndows7 partition is booted open the control panel, select the bitlocker option and then suspend bitlocker, then restart it

image

This has the effect of telling the bitlocker system that you are accepting the current hardware/MBR setting are correct. After this the PC boots as expected

If I were being more sensible I would suspend bitlocker prior to any fiddling about with Windows 8 – but the bits from Build was just too tempting……….

Why can’t I see my custom work item types in Team Explorer?

If you are editing a TFS process template you have the choice editing XML files or using the Process Template Editor within the TFS 2010 PowerTools. Unfortunately neither is fool proof. You can make errors than means the revised template does not fully work.

The worst of these errors will be picked up when upload the process template to a Team project Collection as during this process the XML is validated.

However, this will not find everything. Today after uploading a new process template I found I could not see two of my revised work item type in the list when I tried to create a new work item.

The best way I found to work out the problem was to try to import the .WIT file (from your local copy of the process template) again using either the Visual Studio –> Tools –> Process Editor –> Work item Types –> Import from File, or the command line tool WITIMPORT

In my case I then got the far more useful error

--------------------------
Error
---------------------------
Error importing work item type definition:

TF237094: Field name 'Priority' is used by the field 'Microsoft.VSTS.Common.Priority', so it cannot be used by the field 'MyNewProcess.Priority'.
---------------------------
OK  
---------------------------

This gave me much more information to fix my problem