title: Trying to add an image on the Window throws 'BitmapImage must have IsFrozen set to false to modify.'
body: <p>App.xaml</p>
  
  <pre><code>&lt;Application ...
           StartupUri="Views\MainWindow.xaml"&gt;
  &lt;Application.Resources&gt;
      &lt;ResourceDictionary&gt;
          &lt;ResourceDictionary.MergedDictionaries&gt;
              &lt;ResourceDictionary&gt;
                  &lt;Local:ViewModelLocator x:Key="ViewModelLocator" /&gt;
                  &lt;BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" /&gt;
                  &lt;BitmapImage x:Key="Logo" UriSource="Media/Images/Logo.png" /&gt;
              &lt;/ResourceDictionary&gt;
              &lt;ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" /&gt;
              &lt;ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" /&gt;
              &lt;ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" /&gt;
              &lt;ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" /&gt;
              &lt;ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" /&gt;
          &lt;/ResourceDictionary.MergedDictionaries&gt;
      &lt;/ResourceDictionary&gt;
  &lt;/Application.Resources&gt;
  </code></pre>
  
  <p></p>
  
  <p>MainWindow.xaml</p>
  
  <pre><code>&lt;Image Source="{StaticResource Logo}" Style="{StaticResource LogoStyle}" /&gt;
  </code></pre>
  
  <p>Throws</p>
  
  <blockquote>
    <p>Initialization of 'System.Windows.Media.Imaging.BitmapImage' threw an
    exception.'</p>
  </blockquote>
  
  <p>Inner:</p>
  
  <blockquote>
    <p>Specified value of type 'System.Windows.Media.Imaging.BitmapImage'
    must have IsFrozen set to false to modify.</p>
  </blockquote>
  
  <p>and the debugger is pointing at <code>UriSource</code>.</p>
  
  <p>Stack</p>
  
  <pre><code> at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
     at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
     at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
     at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
     at XXX.Apps.UI.Wpf.App.InitializeComponent() in C:\Projects\XXX\Apps\UI\WPF\src\XXX.Apps.UI.Wpf\App.xaml:line 1
     at XXX.Apps.UI.Wpf.App.Main()
     at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
     at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
     at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
     at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
     at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
     at System.Threading.ThreadHelper.ThreadStart()
  </code></pre>
  
  <p>Inner stack</p>
  
  <pre><code>   at System.Windows.Freezable.WritePreamble()
     at System.Windows.Media.Imaging.BitmapImage.EndInit()
     at MS.Internal.Xaml.Runtime.ClrObjectRuntime.InitializationGuard(XamlType xamlType, Object obj, Boolean begin)
  </code></pre>
  
  <p>Why? How do I fix it? I am on .NET 4.5</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Apparently I don't even need to add the <code>Image</code> to the MainWindow to reproduce the issue. It has something to do with my declaration in App.xaml ...</p>
  
  <p><strong>Edit 2/Fix:</strong></p>
  
  <p>As a temporary work-around I have moved the Logo resource from App.xaml into the Window resources and it works fine. Would be great if I could use it from the App.xaml, though.</p>