As the title suggests, I'd like to rename "App.config" inside the project to a different name other than the default one. 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. 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:
<?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();"):
A first chance exception of type 'System.Configuration.ConfigurationErrorsException' occurred in System.Configuration.dll
您可以编辑预构建事件,以便VS复制文件并将其重命名
xcopy "$(ProjectDir)YourCustomNameInTheProject.config" "$(TargetDir)$(AssemblyName).exe.config*"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.