title: Unable to cast object of type 'System.Windows.Application' to type 'applicationName.App' error
body: <h2>Setup:</h2>
  
  <ul>
  <li>Visual studio 2015 Community </li>
  <li>WPF 4.5 application</li>
  <li>MVVM design structure</li>
  </ul>
  
  <h2>Problem:</h2>
  
  <p>Error which is causing problems is somehow related to the application naming and also to common casting, however, this error appeared after my attempt to alter the <code>project properties</code> on <code>Visual Studio 2015</code>. Particularly the <code>Assembly name</code> and Default <code>namespace</code>. Now I am unable to find the cause and fix it. </p>
  
  <p>Any tips about what would be the right way to proceed? </p>
  
  <p>This error is appearing on the <code>App.xaml</code>:</p>
  
  <blockquote>
    <p>Severity  Code    Description Project File    Line    Suppression State
    Error     Unable to cast object of type 'System.Windows.Application' to
    type
    'FxConnection.App'.   AppName C:\Users*\Documents\Visual
    Studio 2015\Project1\App.xaml 11</p>
  </blockquote>
  
  <p>The line in question is:</p>
  
  <pre><code>&lt;Application.Resources&gt;
          &lt;ResourceDictionary&gt;
              &lt;viewModels:ViewModelLocator x:Key="Locator" d:IsDataSource="True" /&gt;
  </code></pre>
  
  <p>I am using <code>Mvvm light</code> and its <code>viewModelLocator</code> on my project. This error is causing some binding errors when I am trying to use the <code>Locator</code> to find the viewmodels.</p>
  
  <p><strong>EDIT1:</strong></p>
  
  <p>App.xaml</p>
  
  <pre><code>&lt;Application x:Class="FxConnection.App" 
               xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
               xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
               xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
               d1p1:Ignorable="d" xmlns:d1p1="http://schemas.openxmlformats.org/markup-compatibility/2006" 
               xmlns:viewModels="clr-namespace:FxConnection.ViewModels" 
               xmlns:ds="clr-namespace:FxConnection.Helpers"&gt;
      &lt;!-- StartupUri="Views/MainWindow.xaml"--&gt;
      &lt;Application.Resources&gt;
          &lt;ResourceDictionary&gt;
              &lt;viewModels:ViewModelLocator x:Key="Locator" d:IsDataSource="True" /&gt;
              &lt;BitmapImage x:Key="FidelixLogo" CreateOptions="IgnoreImageCache" CacheOption="OnLoad" UriSource="/**/logo.png" /&gt;
              &lt;ResourceDictionary.MergedDictionaries&gt;
                  &lt;ResourceDictionary Source="*******" /&gt;
              &lt;/ResourceDictionary.MergedDictionaries&gt;
          &lt;/ResourceDictionary&gt;
      &lt;/Application.Resources&gt;
  &lt;/Application&gt;
  </code></pre>
  
  <p>App.xaml.cs</p>
  
  <pre><code>using System;
  using System.Deployment.Application;
  using System.Diagnostics;
  using System.Reflection;
  using System.Text;
  using System.Threading;
  using System.Windows;
  using System.Windows.Threading;
  using FxConnection.Properties;
  using FxConnection.Views;
  using FxConnection.Views.ProjectView;
  using GalaSoft.MvvmLight.Threading;
  
  namespace FxConnection
  {
      /// &lt;summary&gt;
      /// Interaction logic for App.xaml
      /// &lt;/summary&gt;
      public partial class App : Application
      {
          protected override void OnStartup(StartupEventArgs e)
          {
              // Handle globally exceptions
  #if DEBUG
              //Application.Current.DispatcherUnhandledException += new DispatcherUnhandledExceptionEventHandler(AppDispatcherUnhandledException);
  #else
              Application.Current.DispatcherUnhandledException += new DispatcherUnhandledExceptionEventHandler(AppDispatcherUnhandledException);
  #endif
              new ProjectDeviceDatabaseView().Show();
              base.OnStartup(e);
              Settings.Default.Reload();
              DispatcherHelper.Initialize();  // allows messenger functionality between threads !
          }
  
          protected override void OnExit(ExitEventArgs e)
          {
              Settings.Default.Save();
              base.OnExit(e);
          }
  
      }
  }
  </code></pre>