Note that there are some explanatory texts on larger screens.

plurals
  1. POVS2008 XAML Designer exception "Key cannot be null" when using default styles from a ResourceDictionary
    primarykey
    data
    text
    <p>I'm using a shared ResourceDictionary to define default styles and having major conflicts with the XAML Designer in Visual Studio 2008. <em>Key cannot be null</em> appears for all attempts to show the XAML design view. </p> <p>The dictionary is merged into App.xaml (to be used by all windows) and has a number of styles setting the defaults for controls, so they are defined as shown below <strong>without a key</strong>. If you add an x:Key attribute to the styles, they are no longer applied by default. I don't want to have to put explicit Style clauses on every control but it looks like I might have to.</p> <pre><code>&lt;ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt; &lt;Style x:Key="windowStyle" TargetType="{x:Type Window}"&gt; &lt;Setter Property="Background" Value="LightGray" /&gt; &lt;/Style&gt; &lt;Style TargetType="{x:Type TextBox}"&gt; &lt;Setter Property="Background" Value="AliceBlue" /&gt; &lt;Setter Property="Height" Value="23" /&gt; &lt;/Style&gt; &lt;/ResourceDictionary&gt; </code></pre> <p>The full exception error message with stack:</p> <pre><code>Key cannot be null. Parameter name: key at System.Collections.Hashtable.get_Item(Object key) at MS.Internal.Xaml.AssemblyNode.For(Assembly assembly, Boolean includeInternal) at MS.Internal.Xaml.ReflectionProjectNode.LoadAssembly(AssemblyName name, Boolean includeInternal) at MS.Internal.Xaml.ReflectionProjectNode.BuildAssemblies() at MS.Internal.Xaml.ReflectionProjectNode.BuildSubsumption() at MS.Internal.Xaml.ReflectionProjectNode.SubsumingNamespace(Identifier identifier) at MS.Internal.Xaml.XmlElement.BuildScope(PrefixScope parentScope, IParseContext context) at MS.Internal.Xaml.XmlElement.FindElementType(PrefixScope parentScope, IParseContext context) at MS.Internal.DocumentTrees.Markup.XamlSourceDocument.get_RootType() at Microsoft.Windows.Design.Documents.Trees.MarkupDocumentTreeManager.get_RootType() at Microsoft.Windows.Design.Documents.MarkupDocumentManager.CalculateLoadErrorState() at Microsoft.Windows.Design.Documents.MarkupDocumentManager.get_LoadState() at MS.Internal.Host.PersistenceSubsystem.Load() at MS.Internal.Host.Designer.Load() at MS.Internal.Designer.VSDesigner.Load() at MS.Internal.Designer.VSIsolatedDesigner.VSIsolatedView.Load() at MS.Internal.Designer.VSIsolatedDesigner.VSIsolatedDesignerFactory.Load(IsolatedView view) at MS.Internal.Host.Isolation.IsolatedDesigner.BootstrapProxy.LoadDesigner(IsolatedDesignerFactory factory, IsolatedView view) at MS.Internal.Host.Isolation.IsolatedDesigner.BootstrapProxy.LoadDesigner(IsolatedDesignerFactory factory, IsolatedView view) at MS.Internal.Host.Isolation.IsolatedDesigner.Load() at MS.Internal.Designer.DesignerPane.LoadDesignerView() </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload