2

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.

Barron879
  • 21
  • 2
  • Is it only the installer's problem? I.e., does the service work OK on the same machine if your register it manually? – noseratio May 01 '14 at 22:35
  • As far as I know, InstallUtil.exe is the way to register a .NET Windows Service. InstallUtil throws this error and so does ISLE, because it's using InstallUtil to register the service. I can install on my development box just fine, and if I install .NET 4.5.1 on a windows 7 machine, it will install fine as well. – Barron879 May 01 '14 at 22:49
  • See if [this post](http://stackoverflow.com/a/20135641/1768303) helps, just substitute `RegAsm.exe` with `InstallUtil.exe`. – noseratio May 01 '14 at 22:56
  • @Noseratio, this worked for InstallUtil.exe! After this, I attempted it with my InstallShield generated setup, and it failed. The FusionLogs show that msiexec.exe is still looking for System.Threading.Tasks version 1.5.11.0 – Barron879 May 02 '14 at 03:41
  • Then vote to fix [this bug](https://connect.microsoft.com/VisualStudio/feedback/details/789318/asyncpack-system-io-fileloadexception-could-not-load-file-or-assembly-system-threading-tasks-version-1-5-11-0). – noseratio May 02 '14 at 03:43
  • 1
    Will do. In the mean time, I discovered that Installshield 2013 LE has unlocked a basic Service installation option so you don't have to use an Installer class in your Windows service to install it. I appreciate all the help. :) – Barron879 May 02 '14 at 12:04

1 Answers1

0

Try to find the answer in this bcl blog link I think that Issue 6 within this page is what you are looking for.

Slava
  • 1,065
  • 5
  • 11
  • Unfortunately, I've been on this blog and tried Issue 6, 7, 8, and 9. I just attempted Issue 6 again on my brand new Service project build and got the same error. – Barron879 May 01 '14 at 22:22