title: C# UWP VS2017 ComboBox event error: unable to activate Windows store app
body: <p>I tried to create an eventhandler for a combobox in an UWP app that when I change the value to a certain item some controls on the form get hidden. The problem is that when I choose to start without debugging I get an error: unable to activate Windows store app. Now I dont know is this is caused by the code or by something else. When I remove the event from the code the problem is gone and if I only remove the body from the eventhandler the problem remains so I am fairly certain the problem is not in the body.</p>
  <p>This is the C# + XAML code:</p>
  <pre><code>private void RoleComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
      {
          if (roleComboBox.SelectionBoxItem.ToString() == &quot;Coach&quot;)
          {
              positionTextBlock.Visibility = Visibility.Collapsed;
              positionComboBox.Visibility = Visibility.Collapsed;
          }
      }
  
  &lt;ComboBox x:Name=&quot;roleComboBox&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;200,84,0,0&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;140&quot; SelectionChanged=&quot;RoleComboBox_SelectionChanged&quot;&gt;
          &lt;ComboBoxItem IsSelected=&quot;True&quot;&gt;-Choose a role-&lt;/ComboBoxItem&gt;
          &lt;ComboBoxItem&gt;Player&lt;/ComboBoxItem&gt;
          &lt;ComboBoxItem&gt;Coach&lt;/ComboBoxItem&gt;
          &lt;ComboBoxItem&gt;Trainer&lt;/ComboBoxItem&gt;
      &lt;/ComboBox&gt;
  </code></pre>
  <p>I first thought the problem was somewhere in VS2017 (also tried 2019) and tried a lot of solutions I found on the internet regarding this problem. After trying solutions for 10+ hours (I never thought the problem was in the code as all the problems on the internet descriped it as a problem with the debugger) I tried to comment the last part I coded as the problem occured at that time and wasnt there before that. This solved my problem so I pinpointed the error to the eventhandler.</p>