remoting作成windows服务后一直无法读取配置文件,可能的原因之一。

当然在这个无法读取配置文件,无法启动通道之前,你必须确认你的配置文件是正确的。正确的动态配置remoting的格式是:

service >serverProviders >channel >channels >application >system.runtime.remoting >configuration >

里面type的格式是

无法启动服务。System.Runtime.Remoting.RemotingException: 因发生异常”System.IO.FileNotFoundException: 系统找不到指定的文件。 (异常来自 HRESULT:0x80070002)

在 System.ConfigServer.RunParser(IConfigHandler factory, String fileName)

在 System.ConfigTreeParser.Parse(String fileName, String configPath, Boolean skipSecurityStuff)

在 System.Runtime.Remoting.RemotingConfigHandler.LoadConfigurationFromXmlFile(String filename)”而无法成功读取 .Config 文件”xxx.WindowsService.exe.config”。

在 System.Runtime.Remoting.RemotingConfigHandler.LoadConfigurationFromXmlFile(String filename)

在 System.Runtime.Remoting.RemotingConfigHandler.DoConfiguration(String filename, Boolean ensureSecurity)

在 System.Runtime.Remoting.RemotingConfiguration.Configure(String filename, Boolean ensureSecurity)

在 xxxx.WindowsService.srvMain.OnStart(String[] args)

在 System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state)

因为我的软件服务端先是做成应用程序,后面才转Windows服务,

所以我可以确认我的代码是没错的,同样REMOTING的配置也是没问题的。

后面用监控WINDOWS文件读取工具,发现里面有一条记录

CreateFile

C:\WINDOWS\system32\HappyWeb.WindowsService.exe.config

NAME NOT FOUND

我猜测着是不是配置文件要放这,想不到还真是。

可是我在GOOGLE上一直搜索不到这种结果,

而网上同学的提示一直是config文件要和exe放在一起,

我想可能是个例吧,如果你也碰到同样的怪事,希望这能帮助到你。

另外也希望高手能解析下为什么。

Original: https://www.cnblogs.com/Blackie/archive/2008/06/30/1232247.html
Author: Blackie
Title: remoting作成windows服务后一直无法读取配置文件,可能的原因之一。

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/684841/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球