简体   繁体   English

将单个项目控制台应用程序作为可执行文件运行时找不到 App.Config

[英]App.Config not found when running single project console app as an executable

When Running a console app packaged to a single.exe with costura.fody I appear to be unable to access my app.config resulting in the error使用 costura.fody 运行打包到 single.exe 的控制台应用程序时,我似乎无法访问我的 app.config 导致错误

System.InvalidOperationException: No connection string named 'volumeEntities' could be found in the application config file. System.InvalidOperationException:在应用程序配置文件中找不到名为“volumeEntities”的连接字符串。 at System.Data.Entity.Internal.LazyInternalConnection.get_ConnectionHasModel()在 System.Data.Entity.Internal.LazyInternalConnection.get_ConnectionHasModel()

When I test in my nunit test project the app.config I added there which contains the connection string works.当我在我的 nunit 测试项目中进行测试时,我在其中添加的 app.config 包含连接字符串有效。

I have an app.config added to the only other project in the solution.我将 app.config 添加到解决方案中的唯一其他项目中。 It contains the correct connection string In properties the Startup Object is set to 'Uploader.Program'它包含正确的连接字符串 在属性中 Startup Object 设置为“Uploader.Program”

Am I missing some way of setting the project as the start up rather than the program class?我是否错过了将项目设置为启动而不是程序 class 的某种方式? How can I get the executable to find the app.config?如何让可执行文件找到 app.config?

Fody costura does not package the app.config file with the executable so that you can change information in the app.config without recompiling. Fody costura 没有 package app.config 文件与可执行文件,因此您可以更改 app.config 中的信息而无需重新编译。 Copy the.exe.config to the same folder as the executable.将.exe.config 复制到与可执行文件相同的文件夹中。

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

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