【发布时间】:2017-03-20 19:32:54
【问题描述】:
问题:在我的开发机器上,一切正常。但是,当我将可执行文件复制到服务器时,我的程序没有启动
到目前为止我所做的:我检查了事件查看器,错误堆栈如下所示:
Application: Project.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.Configuration.ConfigurationErrorsException Stack: at System.Configuration.ClientConfigurationSystem.EnsureInit(System.String) at System.Configuration.ClientConfigurationSystem.PrepareClientConfigSystem(System.String) at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(System.String) at System.Configuration.ConfigurationManager.GetSection(System.String) at System.Configuration.ConfigurationManager.get_ConnectionStrings() at Project.BaseService..ctor() at Project.Service..ctor() at Project.Program.Main()
我在网上查了一下,大多数时候,这个错误是由 .config 文件上的 configSections 的一些错位产生的。为了确保不是这种情况,我清理了 app.config 和 .exe.config 文件(只有该部分存在),但我的程序仍然无法运行。
然后,我从失败的进程生成了一个转储文件,这就是事情变得奇怪的地方:当我调用 ConfigurationManager.ConnectionStrings 时抛出的异常是“配置系统初始化失败”,并带有“添加'第 257 行第 6 位的开始标记与 'connectionManagement' 的结束标记不匹配。第 258 行,第 3 位。内部异常。我仔细检查了我的整个项目,在任何地方都没有对“connectionManagement”的单一引用!我什至尝试检查 AppDomain.CurrentDomain.SetupInformation.ConfigurationFile 的值,它指示正确的配置文件。
通过修复这个 connectionManagement 问题,我可能能够运行我的应用程序,但是你们知道这可能来自哪里吗?
【问题讨论】:
-
看起来您的 xml 标签不匹配。类似于
<tagA><tagB></tagA></tagB>或<tagA><tagB></tagA>。缺少某些东西或嵌套不正确。 -
在整个解决方案中进行全文搜索,“connectionManagement”的所有文件类型。它可能会在 .config 文件中找到匹配项。如果明显,请修复,或发布该文件的相关部分。