title: System.Exception in InitializeComponent()?
body: <p>I have a bizarre problem that is causing us problems.</p>
  
  <p>We have a simple C# Wpf UserControl. Its a progress bar - nothing fancy - just a border that changes size depending on bindings to Value and MaxValue. It works fine 99% of the time and we use it in a dozen or so places in out code - including the splash screen.</p>
  
  <p>It always works fine in the splash screen - so it always loads and works in our app.</p>
  
  <p>The problem is that sometimes (and we can't predict or understand when) the InitializeComponent() call in the progress bar constructor throws a System.Exception. Looking into the progressbar.g.cs file created during compile (obj/Debug folder) I can see that the exception is thrown because the progressbar.xaml file is not found. I have not, of course, changed any code in the g.cs file and I haven't done anything fancy in this UserControl at all.</p>
  
  <p><code>
  System.Exception: The component 'MyProject.ControlLibrary.ProgressBar' does not have a resource identified by the URI '/MyProject.ControlLibrary;component/progressbar.xaml'.
     at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
     at MyProject.ControlLibrary.ProgressBar.InitializeComponent() in d:\Projectfolder\MyProject.ControlLibrary\ProgressBar.xaml:line 1
     at MyProject.ControlLibrary.ProgressBar..ctor() in D:\projectfolder\MyProject.ControlLibrary\ProgressBar.xaml.cs:line 26
     at ProjectName.UI.VideoViewer..ctor() in D:\projectfolder\UI\VideoViewer.xaml.cs:line 26
  Source: PresentationFramework
  </code></p>
  
  <p>I don't understand why the progressbar.xaml resource would go missing sometimes, especially given that it always works fine at least once when the app is run. </p>
  
  <p>The UserControl is contained in a project called MyProject.ControlLibrary.dll. This project seems to be configured correctly as it contains other usercontrols which don't show any problems - except from one other similar UserControl which has identical problems.</p>
  
  <p>I have run out of ideas on this - so any suggestions would be helpful. I am using VisualStudio 2008 and .net 3.5</p>