appname.exe.config not created on windows application

拜拜、爱过 提交于 2019-12-07 18:14:20

问题


When I build a windows application. It does not work because it cannot read my app.config file. I looked in the bin directory and it does not have the appname.exe.config file. If I manually copy over the app.config and rename it the appname.exe.config the application will work..but when I build the project this file is never created automagically. What am I missing? Why is my project not creating it? I have looked through the whole folder structure and there is no other config files.


回答1:


Everyone here is giving you false information I think. I think @bowlturner had it right. According to Microsoft, you do need to set the app.config's Copy to output directory property to either Copy Always or Copy if newer. From Microsoft's MSDN Site:

When you develop in Visual Studio, place the source configuration file for your app in the project directory and set its Copy To Output Directory property to Copy always or Copy if newer. The name of the configuration file is the name of the app with a .config extension. For example, an app called myApp.exe should have a source configuration file called myApp.exe.config.

Visual Studio automatically copies the source configuration file to the directory where the compiled assembly is placed to create the output configuration file, which is deployed with the app.




回答2:


Look on App.config properties, should be:
BuildAction: None
CopyToOutputDirectory: Do not copy
Custom tool and custom tool namespace should be empty

Also try to Rebuild project. Right click on project -> Rebuild




回答3:


Assuming you're using Visual Studio click your config file in the Solution Explorer and and in the Properties panel set Copy To Output Directory to something other than Do Not Copy.



来源:https://stackoverflow.com/questions/31859969/appname-exe-config-not-created-on-windows-application

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!