Working on a side project, I started getting a very odd persistent error. Placing a user control onto a window using the Visual Studio designer gave an error dialog “Provide value on ‘System.Windows.Markup.StaticResourceHolder’ threw an exception.” Hand coding the Xaml for the user control gave the same error:

A thorough consultation with Professor Google and Dr Bing left me none the wiser, as most of the search results were discussing the difference between StaticResource and DynamicResource.

Falling back on the age old technique of “deleting things until it works”, I managed to isolate the source of the problem: My user control used a custom converter defined in a different assembly that wasn’t referenced by my main project. Adding the project reference to my main project fixed the problem.

While I’m pleased to have the problem solved, I’m also frustrated at how long it took me to solve the problem. If the exception included more detail, (e.g. the message “Unable to resolve type StringCaseValueConverter”) then I would have been able to fix things immediately.

Lesson: When throwing an exception, include sufficient information to allow someone to diagnose and fix the fault.

Comments

blog comments powered by Disqus