C#, Windows Service, and Microsoft.Bcl.Async
本文关键字:Bcl Async Microsoft Service Windows and | 更新日期: 2023-09-27 18:01:17
我正在使用Nuget中的Microsoft.Bcl.Async包构建一个c# Windows Service。
一切都很好,但是当我试图将它安装在机器上(XP或Win7<-只有。net 4.0)时,我得到1001错误。这是使用InstallUtil或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目录中。我找了好几天想弄明白这个问题,可我还是不知道。
编辑:奇怪的是,我可以从我的项目中删除所有'async'和'await'关键字,现在使用任何async扩展,如'StreamWriter.WriteLineAsync();并在项目中为Microsoft.Bcl.Async留下引用,服务将安装得很好。当我尝试在我的代码中使用'async'或'await'时,我开始遇到这些问题。
试着在这个bcl博客链接中找到答案我想这一页的第6期就是你要找的