title: Resource Dictionary error during Silverlight app initialisation
body: <p>I've got a problem with a Silverlight application.  It has been working and I haven't changed the code, but I have changed a few other things such as upgrading to VS2012.  I thought all was well with the project post upgrade but have now run in to trouble.</p>
  
  <p>When the application starts it throws an exception during the InitializeComponent call.  It looks like the problem is with the ResourceDictionary, specifically I notice this in the inner exception:</p>
  
  <p>InnerException: System.Collections.Generic.KeyNotFoundException</p>
  
  <p>Which makes me think it's trying to set a property and can't find the key it's looking for in the ResourceDictionary.  I've been tearing my hair out trying to discover how to determine what key it's looking for, can anyone suggest a debugging technique to do this?</p>
  
  <p>The full details of the exception are:</p>
  
  <blockquote>
    <p>System.Windows.Markup.XamlParseException occurred   Message=Set
    property 'System.Windows.FrameworkElement.Style' threw an exception.
    [Line: 228 Position: 64]   LineNumber=228   LinePosition=64<br>
    StackTrace:
           at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
           at MyApp.Silverlight.MainPage.InitializeComponent()
           at MyApp.Silverlight.MainPage..ctor()   InnerException: System.Windows.Markup.XamlParseException
           Message=Failed to assign to property 'System.Windows.ResourceDictionary.Source'. [Line: 5 Position: 36]
           LineNumber=5
           LinePosition=36
           StackTrace:
                at MS.Internal.XcpImports.CreateFromXaml(UnmanagedMemoryStream stream,
    String sourceAssemblyName, Boolean createNamescope, Boolean
    requireDefaultNamespace, Boolean allowEventHandlers, String
    xamlResourceUriString, Boolean isBinaryContent)
                at System.Windows.Controls.Control.GetBuiltInStyle(IntPtr nativeTarget, IntPtr&amp; nativeStyle)
           InnerException: System.Collections.Generic.KeyNotFoundException
                Message=The given key was not present in the dictionary.
                StackTrace:
                     at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
                     at System.Windows.ResourceManagerWrapper.GetResourceForUri(Uri xamlUri,
    Type componentType)
                InnerException:</p>
  </blockquote>
  
  <p>Thanks very much for reading and if you have any suggestions I'll be very grateful.</p>