Month: February 2010

InvalidOperation_EnumFailedVersion when binding data to a Silverlight Chart

This one was a pain.

We’re releasing an analytics application in Silverlight to people inside the BBC. Today is release day, and we had some last-minute tweaks we wanted to roll out. Unfortunately, some of our customers were reporting a strange error when they tried this new version.

Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See


I could identify roughly where it was coming from from the stack trace, but the real pain was, this didn’t happen on my development machine, nor on any other machine in our immediate vicinity. But it happened on the machines of both our main stakeholders.

We narrowed it down to the version of the runtime. All the errors were happening on machines with version 3.0.40723.0 while I was running 3.0.40818.0 (and others in my department were running an even newer version).

The problem happened when binding data to a Silverlight Toolkit chart. It worked fine when using a pie chart, but we’d changed that chart to be a bar chart, which is when the errors appeared. Playing with it, Pie Charts work fine but Line, Bar or Column charts would throw this error.

The stack trace showed a lot of  NotifyDataContextChanged event handling before the error hit. The binding wasn’t complex. I’d set the chart’s DataContext to a list of keyvalue pairs, and set the BarSeries ItemsSource property to {Binding Mode=OneWay}.

To fix this (well, work around it, really) I stopped setting the DataContext of the chart in the code altogether, and in place of that, set the ItemsSource property of the BarSeries directly to the list of pairs. This worked fine, and seemed to avoid the error.

The really mysterious thing is why we never come across issues like this until we’re actually launching it? There’s clearly a Universal law at work.

<!–[if gte mso 9]> Normal 0 false false false EN-GB X-NONE X-NONE MicrosoftInternetExplorer4 <![endif]–><!–[if gte mso 9]> <![endif]–> <!–[endif]–>[InvalidOperation_EnumFailedVersion]
Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See

‘Cannot register duplicate name ‘XXX’ in this scope’ in VS 2010

Here’s a gotcha that was puzzling me yesterday.

I’ve just installed Visual Studio 2010 RC, and was trying it out on my current project. It’s a Silverlight Navigation-style project, but that’s not important to the bug.

I found one page where the Xaml designer wouldn’t handle the page properly – it was throwing exceptions, and the editor was showing an error in the Xaml. The line looked like this:

<local:SimpleConverter x:Name="SimpleConverter"/>

This is a value converter, designed to convert bindings from one type to another. The error it was showing was ‘Cannot register duplicate name ‘SimpleConverter’ in this scope’. This foxed me for a while – I thought perhaps because I was throwing exceptions when I didn’t recognise the type being converted, but even removing that and simplifying didn’t remove the error.

Then I noticed the key word in the error message: ‘Name’.

In Xaml you can use x:Name if you want something in the Xaml linked up to a class variable in your code-behind. But that was clearly causing issues with whatever the designer was doing behind the scenes. However, if you don’t need code-behind access (as I don’t in this case) you can use x:Key – and that’s the usual mechanism for naming resources.

Changing the resource to:

<local:SimpleConverter x:Key="SimpleConverter"/>

then the errors from the visual designer stop happening.

Of course, I’ve no idea if the errors are a bug in the designer, or if it’s just wrong to use x:Name in resources, but since I didn’t need the autowiring up of objects, it’s no problem to change it.