title: Portable Class Library ICommand compilation error in WPF -- Not sure how to resolve this appropriately?
body: <p>Some background information:</p>
  
  <ul>
  <li>I am using VS 2013</li>
  <li>I created a Portable Class Library (Targets: .NET 4.5/Silverlight 5/Win Phone 8/Win Store 8)</li>
  <li>I implemented the <code>ICommand</code> interface in my class named <code>MyCommand</code>.</li>
  </ul>
  
  <p>MyCommand.cs:</p>
  
  <pre><code>public class MyCommand : ICommand
  {
      public bool CanExecute(object parameter)
      {
          throw new NotImplementedException();
      }
  
      public void Execute(object parameter)
      {
          throw new NotImplementedException();
      }
  
      public event EventHandler CanExecuteChanged;
  }
  </code></pre>
  
  <p>I found that when I attempted to reference use the <code>MyCommand</code> class in a WPF 4.5 application, I get the following error:</p>
  
  <blockquote>
    <p>The type 'System.Windows.Input.ICommand' is defined in an assembly
    that is not referenced. You must add a reference to assembly
    'System.Windows, Version=2.0.5.0, Culture=neutral,
    PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'.</p>
  </blockquote>
  
  <p>I'm not really sure <i>why</i> this is happening, or what I can do to resolve it appropriately. After scouring the internet, I found answers talking about adding a reference to <code>System.Windows.dll 4.0.0.0</code> in my WPF application. Doing this allows me to compile and run the application, but my IDE complains that:</p>
  
  <blockquote>
    <p>Interface member 'void
    System.Windows.Markup.IComponentConnector.Connect(in, object)' is not
    implemented.</p>
  </blockquote>
  
  <p>This occurs for my MainWindow.cs class. Is there a better fix than to just deal with this bug so I'm not adding a reference to <code>System.Windows.dll</code> in a WPF application which really doesn't need it? And I say that it doesn't really need it because if I copy/paste the <code>MyCommand</code> class into the Wpf app it works fine. It only has an issue because I am attempting to use it as a portable class library.</p>
  
  <hr>
  
  <p>UPDATE:</p>
  
  <p>It seems that there is more to this than meets the eye. I created a new Wpf Application and used NuGet to reference the MvvmCross solution (since it has an <code>MvxCommand</code> object). When I do this, I get the same error.</p>
  
  <p>David Kean's <a href="https://stackoverflow.com/a/19967939/347172">answer</a> to a similar question suggests that this should be fixed via VS2012/VS2013 and if not, just reinstall/repair. I fully removed my VS installation and reinstalled it from scratch (VS2013) and still have this issue. So, is this truly a bug or did I do something wrong here?</p>
  
  <hr>
  
  <p>UPDATE 2:</p>
  
  <p>I attempted to see if I could assign an instance of the <code>MyCommand</code> class to <code>ICommand</code>: <code>ICommand cmd = new MyCommand();</code> and received the following error:</p>
  
  <blockquote>
    <p>Cannot implicitly convert type 'PortableClassLibrary1.MyCommand' to
    'System.Windows.Input.ICommand'. An explicit conversion exists (are
    you missing a cast?)</p>
  </blockquote>
  
  <p>For some reason the PCL does not seem to type forward the <code>System.Windows.dll [2.0.5.0]</code> ICommand to <code>System.dll [4.0.0.0]</code> ICommand for my desktop application... Ugh!</p>
  
  <hr>
  
  <p>Update 3:</p>
  
  <p>I uploaded <a href="http://s000.tinyupload.com/index.php?file_id=29927554796789144677" rel="nofollow noreferrer">my solution</a> so that it is more visible as to what the problem is.</p>
  
  <hr>
  
  <p>Update 4:</p>
  
  <p>I've opened a <a href="https://connect.microsoft.com/VisualStudio/feedback/details/811512/portable-class-library-forces-me-to-add-system-windows-dll-to-my-wpf-project" rel="nofollow noreferrer">Microsoft connect ticket</a> on this issue.</p>
  
  <hr>
  
  <p>Update 5:</p>
  
  <p>After calming down from being upset about this not working... and others telling me that they don't get the same "interface" error. I realize that the "side-effect" of adding <code>System.Windows.dll</code> was a ReSharper 8.1 error. I guess it's time to complain to ReSharper instead of Microsoft. <em>sigh</em></p>