title: How use and deploy Microsoft.Bcl.Async in .Net 4.0?
body: <p>We have following environment:</p>
  
  <p>1) Third-party desktop application App.exe targeted to .Net 4.0.</p>
  
  <p>2) Our plugin.dll targeted to .Net 4.0 and that is dynamically loaded by the App.exe.</p>
  
  <p>3) Our plugin uses Microsoft.Bcl.Async.</p>
  
  <p>4) Along with our plugin we distribute:</p>
  
  <ul>
  <li>Microsoft.Threadng.Tasks.dll </li>
  <li>Microsoft.Threadng.Tasks.Extensions.dll</li>
  <li>Microsoft.Threadng.Tasks.Extensions.Desktop.dll</li>
  <li>System.Threading.Tasks.dll </li>
  <li>System.IO.dll </li>
  <li>System.Runtime.dll</li>
  </ul>
  
  <p>So, finally we have following directory structure on client system:</p>
  
  <pre><code>App /
      App.exe
      App.config
      plugin.dll
      Microsoft.Threadng.Tasks.dll
      Microsoft.Threadng.Tasks.Extensions.dll
      Microsoft.Threadng.Tasks.Extensions.Desktop.dll
      System.Threading.Tasks.dll
      System.IO.dll
      System.Runtime.dll
  </code></pre>
  
  <p><strong>Our problem</strong> is if client system has .Net 4.5 installed all is working fine, but if client system has .Net 4.0 then the App.exe can't load our plugin:</p>
  
  <p><em>System.IO.FileLoadException
  Could not load file or assembly 'System.Threading.Tasks, Version=1.5.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly manifest definition does not match the assembly reference.</em></p>
  
  <p>If we modify App.config to redirect binding to System.Threading.Tasks from our distribution then error goes away. But this not a good solution I think.</p>
  
  <p>I have a strong opinion that we do something wrong, but I don't have enough experience in .Net to resolve this correctly.</p>
  
  <p>Also, is my guess correct that Bcl.Async allows code thet is targeted to .Net 4.0 use async/await without need to be re-targeted to .Net 4.5?</p>
  
  <p>Can any one help me?</p>
  
  <p><strong>UPDATE Fuslogvw output:</strong></p>
  
  <pre><code>*** Assembly Binder Log Entry  (2/17/2015 @ 5:28:39 PM) ***
  
  The operation failed.
  Bind result: hr = 0x80131040. No description available.
  
  Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
  Running under executable  C:\Program Files (x86)\Third-party App\bin\ThirdParty.App.exe
  --- A detailed error log follows. 
  
  === Pre-bind state information ===
  LOG: User = Administrator
  LOG: DisplayName = System.Threading.Tasks, Version=1.5.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
   (Fully-specified)
  LOG: Appbase = file:///C:/Program Files (x86)/Third-party App/bin/
  LOG: Initial PrivatePath = NULL
  LOG: Dynamic Base = NULL
  LOG: Cache Base = NULL
  LOG: AppName = ThirdParty.App.exe
  Calling assembly : Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.
  ===
  LOG: This bind starts in default load context.
  LOG: Using application configuration file: C:\Program Files (x86)\Third-party App\bin\ThirdParty.App.exe.Config
  LOG: Using host configuration file: 
  LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
  LOG: Post-policy reference: System.Threading.Tasks, Version=1.5.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
  LOG: GAC Lookup was unsuccessful.
  LOG: Attempting download of new URL file:///C:/Program Files (x86)/Third-party App/bin/System.Threading.Tasks.DLL.
  LOG: Assembly download was successful. Attempting setup of file: C:\Program Files (x86)\Third-party App\bin\System.Threading.Tasks.dll
  LOG: Entering run-from-source setup phase.
  LOG: Assembly Name is: System.Threading.Tasks, Version=2.6.8.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
  WRN: Comparing the assembly name resulted in the mismatch: Major Version
  ERR: The assembly reference did not match the assembly definition found.
  ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
  </code></pre>