title: What is this error: System.Runtime.InteropServices.COMException?
body: <p>I keep getting this error:</p>
  
  <pre>
  System.Runtime.InteropServices.COMException was thrown on "C:\Users\---\documents\visual studio 2010\Projects\TBrowser\TBrowser\TBrowserWindow.xaml": Error HRESULT E_FAIL has been returned from a call to a COM component.
  </pre>
  
  <p>But I don't have a <code>COM</code> component in my .xaml file. It keeps popping up and saying the position of the error is line 1 column 1 and I just have a <code>Window</code> there and nothing else:</p>
  
  <pre><code>&lt;Window x:Class="TBrowser.TBrowserWindow"
          xmlns:my="clr-namespace:TBrowser"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          Height="800" Width="900" Icon="/TBrowser;component/Images/Icons/Icon.ico" MinHeight="143" MinWidth="358" Background="White" Loaded="Window_Loaded" Name="TBWindow1"&gt;
      &lt;Window.Resources&gt;
          &lt;ResourceDictionary&gt;
              &lt;ResourceDictionary.MergedDictionaries&gt;
                  &lt;ResourceDictionary Source="Themes/Generic.xaml" /&gt;
              &lt;/ResourceDictionary.MergedDictionaries&gt;
          &lt;/ResourceDictionary&gt;
      &lt;/Window.Resources&gt;
  
      &lt;DockPanel x:Name="Layout"&gt;
          &lt;StatusBar Height="24" Name="TBStatusBar1" Background="WhiteSmoke" BorderBrush="Black" BorderThickness="0,1,0,0" VerticalContentAlignment="Bottom" DockPanel.Dock="Bottom"&gt;
              &lt;StatusBarItem Width="300" HorizontalAlignment="Left" Padding="1" /&gt;
              &lt;StatusBarItem HorizontalAlignment="Right" Padding="0" Margin="1" VerticalContentAlignment="Stretch"&gt;
                  &lt;ProgressBar Width="146" Height="18" HorizontalAlignment="Left" Margin="1" Name="TBProgessBar1"&gt;&lt;/ProgressBar&gt;
              &lt;/StatusBarItem&gt;
          &lt;/StatusBar&gt;
  
          &lt;my:TBOutputPannel x:Name="TBOutputPannel1" DockPanel.Dock="Bottom" MinHeight="48" MaxHeight="200" Visibility="Collapsed" /&gt;
  
          &lt;my:TBControlBar Height="48" VerticalAlignment="Top" x:Name="TBControlBar1" DockPanel.Dock="Top"&gt;
              &lt;my:TBControlBar.ContextMenu&gt;
                  &lt;ContextMenu&gt;
                      &lt;MenuItem Header="Menubar" IsCheckable="True" IsChecked="True" /&gt;
                      &lt;MenuItem Header="Favsbar" IsCheckable="True" IsChecked="True" /&gt;
                      &lt;MenuItem Header="Statusbar" IsCheckable="True" IsChecked="True" /&gt;
                  &lt;/ContextMenu&gt;
              &lt;/my:TBControlBar.ContextMenu&gt;
          &lt;/my:TBControlBar&gt;
          &lt;Grid DockPanel.Dock="Bottom"&gt;
              &lt;my:TBTabControl x:Name="TBTabControl1"&gt;
                  &lt;my:TBAddTabItem Height="28" HorizontalAlignment="Left" IsSelected="False" Margin="0" x:Name="TBAddTabItem" VerticalAlignment="Top" Width="28"&gt;&lt;/my:TBAddTabItem&gt;
              &lt;/my:TBTabControl&gt;
              &lt;Menu Height="24" Name="TBMenu1" VerticalAlignment="Top" Margin="0,29,0,0" Background="WhiteSmoke"&gt;
                  &lt;MenuItem Header="File"&gt;
                      &lt;MenuItem Header="New tab" InputGestureText="Ctrl+T" Click="MenuItem_Click"&gt;
                          &lt;MenuItem.Icon&gt;
                              &lt;Image Source="/TBrowser;component/Images/Images/TBNewTabIcon1.png" /&gt;
                          &lt;/MenuItem.Icon&gt;
                      &lt;/MenuItem&gt;
                      &lt;MenuItem Header="Duplicate tab" InputGestureText="Ctrl+K" Click="MenuItem_Click_1" /&gt;
                      &lt;MenuItem Header="New window" InputGestureText="Ctrl+N" /&gt;
                      &lt;MenuItem Header="New session" /&gt;
                      &lt;MenuItem Command="ApplicationCommands.Open" Header="Open" /&gt;
                      &lt;MenuItem Header="Edit with Notepad" /&gt;
                      &lt;MenuItem Command="ApplicationCommands.Save" Header="Save" IsEnabled="False" /&gt;
                      &lt;MenuItem Command="ApplicationCommands.SaveAs" Header="Save As..." InputGestureText="Ctrl+S" /&gt;
                      &lt;MenuItem Header="Close tab" InputGestureText="Ctrl+W" /&gt;
                      &lt;Separator /&gt;
                      &lt;MenuItem Header="Page setup" /&gt;
                      &lt;MenuItem Command="ApplicationCommands.Print" Header="Print" InputGestureText="Ctrl+P" /&gt;
                      &lt;MenuItem Command="ApplicationCommands.PrintPreview" Header="Print preview" /&gt;
                      &lt;MenuItem /&gt;
                  &lt;/MenuItem&gt;
              &lt;/Menu&gt;
              &lt;ToolBar Height="24" Margin="0,52,0,0" Name="TBFavsbar1" VerticalAlignment="Top" Style="{StaticResource TBFavsbar}"&gt;
                  &lt;my:TBFavsItem isAdder="True" IconSource="/TBrowser;component/Images/Images/TBAddFavs1.png" Margin="2,1,0,0" /&gt;
                  &lt;Separator Margin="2,1,0,0" /&gt;
              &lt;/ToolBar&gt;
          &lt;/Grid&gt;
      &lt;/DockPanel&gt;
  
      &lt;Window.TaskbarItemInfo&gt;
          &lt;TaskbarItemInfo x:Name="Display" /&gt;
      &lt;/Window.TaskbarItemInfo&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>I even keep getting this error: </p>
  
  <pre><code>System.NullReferenceException was unhandled by user code
    Message=Object reference not set to an instance of an object.
    Source=TBrowser
    StackTrace:
         at TBrowser.TBrowserWindow.TBMenubar1ShowButton_Checked(Object sender, RoutedEventArgs e) in C:\Users\---\documents\visual studio 2010\Projects\TBrowser\TBrowser\TBrowserWindow.xaml.cs:line 137
         at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
         at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
         at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
         at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
         at System.Windows.Controls.MenuItem.OnChecked(RoutedEventArgs e)
         at System.Windows.Controls.MenuItem.OnIsCheckedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
         at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
         at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
         at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
         at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry&amp; newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
         at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
         at System.Windows.Baml2006.WpfKnownMemberInvoker.SetValue(Object instance, Object value)
         at MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetValue(XamlMember member, Object obj, Object value)
         at MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetValue(Object inst, XamlMember property, Object value)
  </code></pre>
  
  <p>And this is what im using:</p>
  
  <pre><code>private void TBMenubar1ShowButton_Checked(object sender, RoutedEventArgs e)
  {
      TBMenu1.Visibility = System.Windows.Visibility.Visible;
      TBrowser.Properties.Settings.Default.Menubar = System.Windows.Visibility.Visible;
  }
  </code></pre>
  
  <p>And I don't get whats going on.</p>