title: Run program as .exe dll miss match? (Method not found)
body: <p>I need to get the names from the smartcard on my computer from inside a service.</p>
  
  <p>I have this program to write the names of all smartcards to a file.</p>
  
  <pre><code>using System;
  using System.Threading.Tasks;
  using Windows.Devices.Enumeration;
  using Windows.Devices.SmartCards;
  
  namespace DeviceEnumerationConsoleTest
  {
      class Program
      {
          static void Main(string[] args)
          {
              EnumerateDevices().Wait();
          }
  
          static async Task EnumerateDevices()
          {          
              try
              {
                  string selector = SmartCardReader.GetDeviceSelector();              
                  DeviceInformationCollection devices = await DeviceInformation.FindAllAsync(selector);
                  string ret = "start1 ";
                  foreach (DeviceInformation device in devices)
                  {
                      ret = ret + device.Name + " _ ";
                  }
  
                  System.IO.File.WriteAllText(@"C:\ProgramData\IDNORTH\cards.txt", ret);
  
              }catch(Exception e)
              {
                  System.IO.File.WriteAllText(@"C:\ProgramData\IDNORTH\error.txt", e.Message);
              }
          }
      }
  }
  </code></pre>
  
  <p>This work great when I run it on it's own.</p>
  
  <p>However when I run it from outside it sometimes work and sometimes returns</p>
  
  <p>Method not found: <code>Void System.Threading.Tasks.Task.AddToActiveTasks(System.Threading.Tasks.Task)</code>.</p>
  
  <p>from line:</p>
  
  <pre><code>DeviceInformationCollection devices = await DeviceInformation.FindAllAsync(selector);
  </code></pre>
  
  <p>I believe from the error there is some problem with the dlls.
  In project I have added the references.</p>
  
  <p>C:\Program Files (x86)\Windows Kits\8.1\References\CommonConfiguration\Neutral\Windows.winm‌​d </p>
  
  <p>and </p>
  
  <p>C:\Program Files (x86)\Microsoft SDKs\WindowsPhoneApp\v8.1\Tools\MDILXAPCompile\Framework\Sys‌​tem.Runtime.WindowsR‌​untime.dll</p>
  
  <p>I call the exe from a service and have not added or changed any references in that. It has the same windows reference as the one added to Project1.</p>