[英]Visual Studio: Custom name for “App.config” in project, not outside project?
As the title suggests, I'd like to rename "App.config" inside the project to a different name other than the default one. 顾名思义,我想将项目内的“ App.config”重命名为默认名称以外的其他名称。 I know it gets renamed to the project name after you build the solution, but it bugs me that I can't give it a diferent name inside the project, before I build...
我知道您在构建解决方案后将其重命名为项目名称,但这使我感到困惑,因为在构建之前,我无法在项目内部给它一个不同的名称。
Example: My solution name is "Test123", and I'd like to have the config file named "Test123.config" before the project gets built. 示例:我的解决方案名称是“ Test123”,在构建项目之前,我想将配置文件命名为“ Test123.config”。 I don't care what name it has afterwards.
我不在乎它的名字叫什么。
Okay. 好的。 I've redone everything and I have the app.config file with the following structure in my project:
我已经重做了所有事情,并且在我的项目中有以下结构的app.config文件:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="Codex.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<Codex.Properties.Settings>
<setting name="Location" serializeAs="String">
<value>0, 0</value>
</setting>
</Codex.Properties.Settings>
</userSettings>
After I rename it to "Codex.config" inside the project, and I debug the application I get this error when running (and I also get it when I try to close the application from the "X" button (when doing "Properties.Settings.Default.Save();"): 将其重命名为项目内的“ Codex.config”,并调试应用程序后,在运行时会出现此错误(当我尝试通过“ X”按钮关闭应用程序(执行“属性”时,也会遇到此错误)。 Settings.Default.Save();“):
A first chance exception of type 'System.Configuration.ConfigurationErrorsException' occurred in System.Configuration.dll
您可以编辑预构建事件,以便VS复制文件并将其重命名
xcopy "$(ProjectDir)YourCustomNameInTheProject.config" "$(TargetDir)$(AssemblyName).exe.config*"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.