title: C# WPF XAML, Adding ComboBox_SelectionChanged causes .pdb not loaded error
body: <p>Ok, I have a very simple project to learn about WPF following this video tutorial:
  <a href="https://www.youtube.com/watch?v=Vjldip84CXQ" rel="nofollow noreferrer">https://www.youtube.com/watch?v=Vjldip84CXQ</a></p>
  
  <p>Everything is OK (and by OK I mean the project <strong>can be built AND run</strong>)... until I try to change a little part in the XAML from:</p>
  
  <pre><code>  &lt;ComboBox SelectedIndex="0"&gt;
      &lt;ComboBoxItem&gt;Painted&lt;/ComboBoxItem&gt;
      &lt;ComboBoxItem&gt;Not Painted&lt;/ComboBoxItem&gt;
    &lt;/ComboBox&gt;
  </code></pre>
  
  <p>to:</p>
  
  <pre><code>  &lt;ComboBox x:Name="FinishComboBox" SelectedIndex="0" SelectionChanged="FinishComboBox_SelectionChanged"&gt;
      &lt;ComboBoxItem&gt;Painted&lt;/ComboBoxItem&gt;
      &lt;ComboBoxItem&gt;Not Painted&lt;/ComboBoxItem&gt;
    &lt;/ComboBox&gt;
  </code></pre>
  
  <p>Then it gives me this error, "PresentationFramework.pdb not loaded". And, strangely - at least to me, the solution <strong>can be built but CANNOT be run</strong>. The error is generated when I try to run (such as by pressing F5 in VS) the solution.</p>
  
  <p><a href="https://i.stack.imgur.com/CrNz3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CrNz3.png" alt="enter image description here"></a> </p>
  
  <p>And yes, it is really caused by the XAML change, because if I change the XAML back to:</p>
  
  <pre><code>  &lt;!--&lt;ComboBox x:Name="FinishComboBox" SelectedIndex="0" SelectionChanged="FinishComboBox_SelectionChanged"&gt;--&gt;
    &lt;ComboBox SelectedIndex="0"&gt;
      &lt;ComboBoxItem&gt;Painted&lt;/ComboBoxItem&gt;
      &lt;ComboBoxItem&gt;Not Painted&lt;/ComboBoxItem&gt;
    &lt;/ComboBox&gt;
  </code></pre>
  
  <p>It is working, clean and fine. So my question is obviously <em>why is this so</em>?</p>
  
  <p>I tried some solutions like suggested in:</p>
  
  <ul>
  <li><a href="https://social.msdn.microsoft.com/Forums/en-US/4c4e2a48-f847-4b94-8adc-58dd000b13ca/visual-studio-presentation-framework-not-loaded?forum=wpf" rel="nofollow noreferrer">https://social.msdn.microsoft.com/Forums/en-US/4c4e2a48-f847-4b94-8adc-58dd000b13ca/visual-studio-presentation-framework-not-loaded?forum=wpf</a></li>
  <li><a href="https://stackoverflow.com/questions/18109575/symbol-file-not-loading-for-debugging-custom-project-in-visual-studio-2012">Symbol file not loading for debugging custom project in Visual Studio 2012</a></li>
  </ul>
  
  <p>That includes:</p>
  
  <ol>
  <li>deleted bin and obj folder from the startup project folder and rebuild the solution</li>
  <li>delete reference to the PresentationFramework then retarget your application framwork and then add PresentationFramework reference again or modified some debug options, clean and rebuild the project.</li>
  <li>Change settings in Debug -> Options -> Debugging -> General, uncheck "Require source files to exactly match the original version"</li>
  <li>Do "Load all symbols" and "Empty Symbol Cache" in Debug -> Options -> Debugging -> Symbols for "All modules, unless excluded"</li>
  <li>some other little things...</li>
  </ol>
  
  <p>But nothing works. Any other solution?</p>
  
  <p>Here is my complete code:</p>
  
  <p><strong>C#</strong></p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.Windows;
  using System.Windows.Controls;
  using System.Windows.Data;
  using System.Windows.Documents;
  using System.Windows.Input;
  using System.Windows.Media;
  using System.Windows.Media.Imaging;
  using System.Windows.Navigation;
  using System.Windows.Shapes;
  
  namespace WpfBasics {
    /// &lt;summary&gt;
    /// Interaction logic for MainWindow.xaml
    /// &lt;/summary&gt;
    public partial class MainWindow : Window {
      public MainWindow() {
        InitializeComponent();
      }
  
      private void ApplyButton_Click(object sender, RoutedEventArgs e) {
        MessageBox.Show($"The description is: {DescriptionText.Text}"); //See how crazy C# is when making things easy for string printing AND it can handle null!!
      }
  
      private void ResetButton_Click(object sender, RoutedEventArgs e) {
        WeldCheckBox.IsChecked = AssemblyCheckBox.IsChecked = PlasmaCheckBox.IsChecked = LaserCheckBox.IsChecked = PurchaseCheckBox.IsChecked = 
        LatheCheckBox.IsChecked = DrillCheckBox.IsChecked = FoldCheckBox.IsChecked = RollCheckBox.IsChecked = SawCheckBox.IsChecked = false;
      }
  
      private void CheckBox_Checked(object sender, RoutedEventArgs e) {
        int length = string.IsNullOrWhiteSpace(LengthText.Text) ? 0 : int.Parse(LengthText.Text);
        length += ((CheckBox)sender).Content.ToString().Length;
        LengthText.Text = length.ToString();
      }
  
      private void CheckBox_Unchecked(object sender, RoutedEventArgs e) {
        int length = string.IsNullOrWhiteSpace(LengthText.Text) ? 0 : int.Parse(LengthText.Text);
        length -= ((CheckBox)sender).Content.ToString().Length;
        LengthText.Text = length.ToString();
      }
  
      private void FinishComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) {
        var comboBox = (ComboBox)sender;
        var value = (ComboBoxItem)comboBox.SelectedValue;
        NoteText.Text = (string)value.Content;
      }
    }
  }
  </code></pre>
  
  <p><strong>XAML</strong></p>
  
  <pre><code>&lt;Window x:Class="WpfBasics.MainWindow"
          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"
          xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
          xmlns:local="clr-namespace:WpfBasics"
          mc:Ignorable="d"
          Title="WPF Basics v1.0" Height="800" Width="400"&gt;
  
    &lt;Border Padding="10"&gt;
      &lt;StackPanel&gt;
        &lt;Grid&gt;
          &lt;Grid.ColumnDefinitions&gt;
            &lt;ColumnDefinition Width="*"/&gt;
            &lt;ColumnDefinition Width="*"/&gt;
            &lt;ColumnDefinition Width="*"/&gt;
          &lt;/Grid.ColumnDefinitions&gt;
          &lt;Button x:Name="ApplyButton" Click="ApplyButton_Click" Margin="0 0 10 0" Grid.Column="0" Content="Apply"/&gt;
          &lt;Button x:Name="ResetButton" Click="ResetButton_Click" Margin="0 0 0 0" Grid.Column="1" Content="Reset"/&gt;
          &lt;Button Margin="10 0 0 0" Grid.Column="2" Content="Refresh"/&gt;
        &lt;/Grid&gt;
  
        &lt;!--Margin shorthand 0 10 means left-right = 0, top bottom = 10--&gt;
        &lt;!--Pulse Properties--&gt;
        &lt;TextBlock Text="Pulse Properties" FontWeight="Bold" Margin="0 10"/&gt;
  
        &lt;!--Description--&gt;
        &lt;TextBlock Text="Description"/&gt;
        &lt;TextBox x:Name="DescriptionText" Padding="2" /&gt;
  
        &lt;!--Status and Revision--&gt;
        &lt;Grid Margin="0 5 0 0"&gt;
          &lt;Grid.ColumnDefinitions&gt;
            &lt;ColumnDefinition Width="2*"/&gt;
            &lt;ColumnDefinition Width="*"/&gt;
          &lt;/Grid.ColumnDefinitions&gt;
  
          &lt;StackPanel Grid.Column="0" Margin="0 0 10 0"&gt;
            &lt;TextBlock Text="Status"/&gt;
            &lt;TextBox Padding="2" IsReadOnly="True" Background="#eeeeee"/&gt;
          &lt;/StackPanel&gt;
  
          &lt;StackPanel Grid.Column="1"&gt;
            &lt;TextBlock Text="Revision"/&gt;
            &lt;TextBox Padding="2" IsReadOnly="True" Background="#eeeeee"/&gt;
          &lt;/StackPanel&gt;
  
        &lt;/Grid&gt;
  
        &lt;!--Part Number--&gt;
        &lt;TextBlock Text="Part Number" Margin="0 5 0 0"/&gt;
        &lt;TextBox Padding="2" IsReadOnly="True" Background="#eeeeee"/&gt;
  
        &lt;!--Raw Material--&gt;
        &lt;TextBlock Text="Raw Material" FontWeight="Bold" Margin="0 10"/&gt;
  
        &lt;!--Material--&gt;
        &lt;TextBlock Text="Material"/&gt;
        &lt;ComboBox /&gt;
  
        &lt;!--Manufacturing Info--&gt;
        &lt;TextBlock Text="Manufacturing Info" FontWeight="Bold" Margin="0 10"/&gt;
  
        &lt;!--Work Centres--&gt;
        &lt;TextBlock Text="Work Centres"/&gt;
  
        &lt;!--Checkboxes--&gt;
        &lt;Grid&gt;
          &lt;Grid.ColumnDefinitions&gt;
            &lt;ColumnDefinition Width="*"/&gt;
            &lt;ColumnDefinition Width="*"/&gt;
          &lt;/Grid.ColumnDefinitions&gt;
  
          &lt;StackPanel Grid.Column="0" Margin="0 0 10 0"&gt;
            &lt;CheckBox Unchecked="CheckBox_Unchecked" Checked="CheckBox_Checked" x:Name="WeldCheckBox" Content="Weld"/&gt;
            &lt;CheckBox Unchecked="CheckBox_Unchecked" Checked="CheckBox_Checked" x:Name="AssemblyCheckBox" Content="Assembly"/&gt;
            &lt;CheckBox Unchecked="CheckBox_Unchecked" Checked="CheckBox_Checked" x:Name="PlasmaCheckBox" Content="Plasma"/&gt;
            &lt;CheckBox Unchecked="CheckBox_Unchecked" Checked="CheckBox_Checked" x:Name="LaserCheckBox" Content="Laser"/&gt;
            &lt;CheckBox Unchecked="CheckBox_Unchecked" Checked="CheckBox_Checked" x:Name="PurchaseCheckBox" Content="Purchase"/&gt;
          &lt;/StackPanel&gt;
  
          &lt;StackPanel Grid.Column="1"&gt;
            &lt;CheckBox Unchecked="CheckBox_Unchecked" Checked="CheckBox_Checked" x:Name="LatheCheckBox" Content="Lathe"/&gt;
            &lt;CheckBox Unchecked="CheckBox_Unchecked" Checked="CheckBox_Checked" x:Name="DrillCheckBox" Content="Drill"/&gt;
            &lt;CheckBox Unchecked="CheckBox_Unchecked" Checked="CheckBox_Checked" x:Name="FoldCheckBox" Content="Fold"/&gt;
            &lt;CheckBox Unchecked="CheckBox_Unchecked" Checked="CheckBox_Checked" x:Name="RollCheckBox" Content="Roll"/&gt;
            &lt;CheckBox Unchecked="CheckBox_Unchecked" Checked="CheckBox_Checked" x:Name="SawCheckBox" Content="Saw"/&gt;
          &lt;/StackPanel&gt;
        &lt;/Grid&gt;
  
        &lt;!--Length--&gt;
        &lt;TextBlock Text="Length" Margin="0 5 0 0"/&gt;
        &lt;TextBox x:Name="LengthText" Padding="2"/&gt;
  
        &lt;!--Mass--&gt;
        &lt;TextBlock Text="Mass" Margin="0 5 0 0"/&gt;
        &lt;TextBox x:Name="MassText" Padding="2" IsReadOnly="True" Background="#eeeeee"/&gt;
  
        &lt;!--Finish--&gt;
        &lt;TextBlock Text="Finish" Margin="0 5 0 0"/&gt;
        &lt;ComboBox x:Name="FinishComboBox" SelectedIndex="0" SelectionChanged="FinishComboBox_SelectionChanged"&gt;
        &lt;!--ok if I use the code below--&gt;
        &lt;!--&lt;ComboBox SelectedIndex="0"&gt;--&gt;
          &lt;ComboBoxItem&gt;Painted&lt;/ComboBoxItem&gt;
          &lt;ComboBoxItem&gt;Not Painted&lt;/ComboBoxItem&gt;
        &lt;/ComboBox&gt;
  
        &lt;!--Purchase Information--&gt;
        &lt;TextBlock Text="Purchase Information" Margin="0 5 0 0"/&gt;
        &lt;ComboBox SelectedIndex="0"&gt;
          &lt;ComboBoxItem&gt;Rubber&lt;/ComboBoxItem&gt;
          &lt;ComboBoxItem&gt;Not Rubber&lt;/ComboBoxItem&gt;
        &lt;/ComboBox&gt;
  
        &lt;!--Supplier Name--&gt;
        &lt;TextBlock Text="Supplier Name" Margin="0 5 0 0"/&gt;
        &lt;TextBox Padding="2"/&gt;
  
        &lt;!--Supplier Code--&gt;
        &lt;TextBlock Text="Supplier Code" Margin="0 5 0 0"/&gt;
        &lt;TextBox Padding="2"/&gt;
  
        &lt;!--Additional Information--&gt;
        &lt;TextBlock Text="Additional Information" FontWeight="Bold" Margin="0 10"/&gt;
  
        &lt;!--Note--&gt;
        &lt;TextBlock Text="Note"/&gt;
        &lt;TextBox x:Name="NoteText" Padding="2"/&gt;
  
      &lt;/StackPanel&gt;
    &lt;/Border&gt;
  &lt;/Window&gt;
  </code></pre>