I'm building a C# Windows Service using the Microsoft.Bcl.Async package from Nuget.
Everything builds fine, but when I try to install it on a machine (XP or Win7<- With only .NET 4.0), I get a 1001 error. This is using InstallUtil OR InstallShield 2013 LE with an Installer Class.
I turned on Fusion logging, and this is the part where it's failing:
*** Assembly Binder Log Entry (5/1/2014 @ 1:23:13 PM) ***
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = someuser
LOG: DisplayName = System.Threading.Tasks, Version=1.5.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
(Fully-specified)
LOG: Appbase = file:///C:/WINDOWS/Microsoft.NET/Framework/v4.0.30319/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = InstallUtil.exe
Calling assembly : Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.
===
LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: Using application configuration file: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\InstallUtil.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: The same bind was seen before, and was failed with hr = 0x80070002.
ERR: Unrecoverable error occurred during pre-download check (hr = 0x80070002).
I've even tried building the service from scratch and immediately installing Microsoft.Bcl.Async to end in the same result.
I have not referenced a different version of System.Threading.Tasks. It is in the bin directory for my service. I have scoured for days trying to figure this out and I'm at a loss.
EDIT: What's curious is that I can remove all 'async' and 'await' keywords from my project and now using any async extensions like 'StreamWriter.WriteLineAsync(); and leave the references in the project for Microsoft.Bcl.Async and the service will install just fine. As soon as I try to use 'async' or 'await' in my code is when I start experiencing these issues.