【发布时间】:2020-11-05 10:01:19
【问题描述】:
我已经与一个问题作斗争好几天了。在我们的解决方案中,我们有一个老化的单体,包括各种 ASP.NET 技术、一个 WCF 服务和几个其他 Windows 服务。一切都是为我的同事构建的,并且服务都正确启动。我有一段时间没有在单体应用上工作了,当我把注意力转向它时,我遇到了一些各种各样的错误,包括一个我还没有解决的错误。为了让我们的 WCF 工作正常,我们必须运行一个充当 WCF 主机的 Windows 服务。当我尝试启动此服务时,它会爆炸,弹出此对话框:
Windows 无法在本地计算机上启动 {name of service} 服务。 错误1064:服务处理控制请求时发生异常。
检查事件查看器,我在 Windows 日志/应用程序中发现了这个 .NET 运行时错误:
Application: {redacted full path/name of WCF service host}.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.FileNotFoundException
Exception Info: System.IO.FileNotFoundException
at System.ServiceModel.Channels.HttpChannelListener..ctor(System.ServiceModel.Channels.HttpTransportBindingElement, System.ServiceModel.Channels.BindingContext)
at System.ServiceModel.Channels.HttpChannelListener`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]..ctor(System.ServiceModel.Channels.HttpTransportBindingElement, System.ServiceModel.Channels.BindingContext)
at System.ServiceModel.Channels.HttpTransportBindingElement.BuildChannelListener[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.ServiceModel.Channels.BindingContext)
at System.ServiceModel.Channels.Binding.BuildChannelListener[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Uri, System.String, System.ServiceModel.Description.ListenUriMode, System.ServiceModel.Channels.BindingParameterCollection)
at System.ServiceModel.Description.ServiceMetadataExtension.CreateGetDispatcher(System.Uri, System.ServiceModel.Channels.Binding, System.String)
at System.ServiceModel.Description.ServiceMetadataExtension.EnsureGetDispatcher(System.Uri, Boolean)
at System.ServiceModel.Description.ServiceMetadataBehavior.EnsureGetDispatcher(System.ServiceModel.ServiceHostBase, System.ServiceModel.Description.ServiceMetadataExtension, System.Uri, System.String)
at System.ServiceModel.Description.ServiceMetadataBehavior.CreateHttpGetEndpoints(System.ServiceModel.Description.ServiceDescription, System.ServiceModel.ServiceHostBase, System.ServiceModel.Description.ServiceMetadataExtension)
at System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(System.ServiceModel.Description.ServiceDescription, System.ServiceModel.ServiceHostBase)
at System.ServiceModel.ServiceHostBase.InitializeRuntime()
at System.ServiceModel.ServiceHostBase.OnOpen(System.TimeSpan)
at System.ServiceModel.Channels.CommunicationObject.Open(System.TimeSpan)
at {elided - a few more stack trace lines referring to our custom code}
同样在同一个事件查看器日志中,我有这个应用程序错误(紧接在 .NET 运行时之后):
Faulting application name: {service name}.exe, version: 4.2.0.0, time stamp: 0x5f0f45ce
Faulting module name: KERNELBASE.dll, version: 10.0.18362.815, time stamp: 0xb89efff3
Exception code: 0xe0434352
Fault offset: 0x000000000003a799
Faulting process id: 0xd84
Faulting application start time: 0x01d65ad32192a62b
Faulting application path: {full service path/name}.exe
Faulting module path: C:\WINDOWS\System32\KERNELBASE.dll
Report Id: 1db8e59a-b3a0-47e3-bb0f-5d8c6e2f8ed5
Faulting package full name:
Faulting package-relative application ID:
在过去的一年半里,我主要在 .NET Core 和 VS 2019 中工作,所以我想可能是框架所需的一些配置或 SDK 丢失了。我的机器上还有 2017 年,这就是我的同事更喜欢使用这个单一的解决方案。现在,这几天,我做了以下事情:
- 删除和/或安装了各种 SDK 和定位包
- 已修复 VS 2017
- 卸载并重新安装 VS 2017
- 已修复 VS 2019
- 卸载并重新安装VS 2019
- 多次卸载并重新安装 Windows 服务
我从头顶的网络搜索结果中获得了最模糊的提示,即某些绑定重定向可能存在问题。最初我可以发誓我看到了 FileNotFound 是 System.Net.Http 中的东西的证据,但现在我似乎找不到任何对我表明的东西。在这一点上,我完全被它烧毁了,我正在考虑只擦除整个系统并从干净的 Windows 安装开始。如果我不得不这样做,那将是一个真正的耻辱。如果您对在哪里寻找或尝试什么有最模糊的提示,我们将不胜感激。
【问题讨论】:
-
是的。事实证明,必须在所有 app.cong 文件中手动更改 System.Net.Http 的绑定重定向。我不知道为什么,但它奏效了。不过,我的意思是说您的回答可能对处于类似情况的其他人有所帮助。
标签: c# .net wcf windows-services