title: XAML Designer Could not load file or assembly
body: <p>I'm trying to have a design time data service, so that I have some data to work with in my XAML.
  I am using the OpenhardwareMonitor library to get the PC's hardware information.</p>
  
  <p>I have code that extracts all sensors that are of the type "SensorType.Power", and shows them in an ItemsControl:</p>
  
  <pre><code>    &lt;ItemsControl
          ItemsSource="{Binding Sensors}"
          ScrollViewer.HorizontalScrollBarVisibility="Auto"
          ScrollViewer.VerticalScrollBarVisibility="Auto"
          Height="100"
          Margin="5,5,5,0"
          Grid.Row="0"&gt;
          &lt;ItemsControl.ItemTemplate&gt;
              &lt;DataTemplate DataType="{x:Type models:HardwareSensorCollection}"&gt;
                  &lt;Grid&gt;
                      &lt;Grid.RowDefinitions&gt;
                          &lt;RowDefinition /&gt;
                          &lt;RowDefinition /&gt;
                      &lt;/Grid.RowDefinitions&gt;
  
                      &lt;TextBlock Text="{Binding Hardware, Converter={StaticResource HardwareNameTypeConcatConverter}}" Grid.Row="0" /&gt;
                      &lt;ItemsControl ItemsSource="{Binding PowerSensors}" DisplayMemberPath="Name" Grid.Row="1" Margin="5,0,0,0" /&gt;
                  &lt;/Grid&gt;
              &lt;/DataTemplate&gt;
          &lt;/ItemsControl.ItemTemplate&gt;
      &lt;/ItemsControl&gt;
  </code></pre>
  
  <p>The code to get the sensors is (during runtime) executed in the Loaded event of my view. In design time, I simply call my view model it's Loaded() method. I am using MVVM, so I used the following to pass that even through to my view model:</p>
  
  <pre><code>&lt;i:Interaction.Triggers&gt;
      &lt;i:EventTrigger EventName="Loaded"&gt;
          &lt;cmd:EventToCommand Command="{Binding Mode=OneWay, Path=LoadedCommand}" /&gt;
      &lt;/i:EventTrigger&gt;
  &lt;/i:Interaction.Triggers&gt;
  </code></pre>
  
  <p>The code to get the sensors is all fine, and works perfectly in runtime. However, when executed in design time, it generates the following error in the design view of Visual Studio:</p>
  
  <pre><code>FileNotFoundException: Could not load file or assembly 'OpenHardwareMonitorLib, Version=0.7.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
  
     at PowerMonitor.DesignData.DesignDataService.&lt;&gt;c__DisplayClass0.&lt;GetHardwareSensorCollections&gt;b__1()
     at System.Threading.Tasks.Task`1.InnerInvoke()
     at System.Threading.Tasks.Task.Execute()
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
     at PowerMonitor.ViewModels.MainViewModel.&lt;Loaded&gt;d__1.MoveNext()
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.CompilerServices.AsyncMethodBuilderCore.&lt;ThrowAsync&gt;b__3(Object state)
     at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
     at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
  </code></pre>
  
  <p>I'm working in VS 2015, but the same error occurs in VS 2013.</p>
  
  <p>I thought, maybe it somehow can't get the sensors when running design time, so I created a couple of classes that would inherit IHardware, and ISensor, so that I could initialize it like this:</p>
  
  <pre><code>var hardwareCollection1 = new HardwareSensorCollection(new DesignHardware("Example Hardware 1", HardwareType.CPU));
  hardwareCollection1.PowerSensors.Add(new DesignSensor("Example Sensor 1", SensorType.Power));
  hardwareCollection1.PowerSensors.Add(new DesignSensor("Example Sensor 2", SensorType.Power));
  
  var hardwareCollection2 = new HardwareSensorCollection(new DesignHardware("Example Hardware 2", HardwareType.CPU));
  hardwareCollection2.PowerSensors.Add(new DesignSensor("Example Sensor 1", SensorType.Power));
  hardwareCollection2.PowerSensors.Add(new DesignSensor("Example Sensor 2", SensorType.Power));
  hardwareCollection2.PowerSensors.Add(new DesignSensor("Example Sensor 3", SensorType.Power));
  hardwareCollection2.PowerSensors.Add(new DesignSensor("Example Sensor 4", SensorType.Power));
  
  return new List&lt;HardwareSensorCollection&gt; { hardwareCollection1, hardwareCollection2 };
  </code></pre>
  
  <p>But that gave me the same error.</p>
  
  <p>I've found a few questions with people having similar problems, but none of their solutions worked for me. I'm thinking that I have to place this DLL somewhere so that VS can find it when it's calling the design time code.</p>
  
  <p>Any ideas?</p>