C#,Windows服务和Microsoft.Bcl.Async

时间:2014-05-01 18:43:41

标签: c# .net windows asynchronous service

我正在使用Nuget的Microsoft.Bcl.Async软件包构建C#Windows服务。

一切都很好,但是当我尝试将它安装在一台机器上(XP或Win7< - 只有.NET 4.0)时,我收到1001错误。这是使用InstallUtil OR InstallShield 2013 LE和安装程序类。

我启用了Fusion日志记录,这是它失败的部分:

*** 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).

我甚至尝试从头开始构建服务并立即安装Microsoft.Bcl.Async以结束相同的结果。

我没有引用不同版本的System.Threading.Tasks。它位于我的服务的bin目录中。我已经冲了几天试图解决这个问题而且我很茫然。

编辑:奇怪的是,我可以从项目中删除所有“异步”和“等待”关键字,现在使用任何异步扩展,如'StreamWriter.WriteLineAsync();并将项目中的引用保留为Microsoft.Bcl.Async,该服务将安装正常。一旦我尝试在我的代码中使用'async'或'await'就是我开始遇到这些问题的时候。

1 个答案:

答案 0 :(得分:0)

尝试在this bcl blog link中找到答案 我认为本页面中的第6期正是您所寻找的。