简体   繁体   English

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

[英]C#, Windows Service, and Microsoft.Bcl.Async

I'm building a C# Windows Service using the Microsoft.Bcl.Async package from Nuget. 我正在使用Nuget的Microsoft.Bcl.Async包构建C#Windows服务。

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. 一切正常,但是当我尝试将其安装在计算机(XP或Win7 <-仅使用.NET 4.0)上时,出现1001错误。 This is using InstallUtil OR InstallShield 2013 LE with an Installer Class. 这是将InstallUtil或InstallShield 2013 LE与Installer类一起使用。

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. 我什至尝试从头开始构建服务,并立即安装Microsoft.Bcl.Async以得到相同的结果。

I have not referenced a different version of System.Threading.Tasks. 我没有引用其他版本的System.Threading.Tasks。 It is in the bin directory for my service. 它在我的服务的bin目录中。 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(); 编辑:很好奇的是,我可以从项目中删除所有“异步”和“等待”关键字,现在可以使用任何异步扩展,例如“ StreamWriter.WriteLineAsync();”。 and leave the references in the project for Microsoft.Bcl.Async and the service will install just fine. 并在项目中保留对Microsoft.Bcl.Async的引用,该服务将安装得很好。 As soon as I try to use 'async' or 'await' in my code is when I start experiencing these issues. 当我尝试在代码中使用'async'或'await'时,就是开始遇到这些问题。

尝试在此bcl博客链接中找到答案,我认为您正在寻找此页面中的第6期。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM