27

My app.config was giving me several messages related to "usersettings schema not found", so I deleted it with the intention of building it from scratch, but I was not successful. How can I build a new one based on my settings file? Whenever I make a new one and build the solution, it doesn't build the app config file. I don't know what else to try.

Here's the troublesome part of my old file:

<startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
</startup>
<userSettings>
    <DelocksNote.Settings1>
        <setting name="Font" serializeAs="String">
            <value>DejaVu Sans, 20.25pt, style=Italic</value>
        </setting>
        <setting name="WordWrap" serializeAs="String">
            <value>False</value>
        </setting>
    </DelocksNote.Settings1>
</userSettings>
Grant Winney
  • 65,241
  • 13
  • 115
  • 165
Solorzano Jose
  • 602
  • 2
  • 8
  • 17

2 Answers2

72

For anyone visiting in the future...

Delete the app.config file in your solution explorer. Right click the project and select add, add new item. Find "Application Configuration File" in the list and add it. It will be empty.

To generate the contents based on your settings (which should still be in tact): edit a setting (make a space or something) and save. Then go look at your new app.config file. It will be re-built!

HeyThereLameMan
  • 886
  • 8
  • 6
  • 1
    Don't forget to update service references (right click service under service references project folder and click update service references) – nurettin Mar 19 '17 at 17:04
  • 2
    No need to add. Just deleting the file is enough. After a rebuild, the file will be recreated. – Kurt Van den Branden Feb 05 '18 at 13:01
  • I had a assembly reference with some build numbers, i removed that whole part of assembly reference and then i recompiled and it worked perfectly :) – Chandraprakash Oct 30 '19 at 18:29
3

In Package Manager Console, run this:

Get-Project –All | Add-BindingRedirect

https://weblog.west-wind.com/posts/2014/nov/29/updating-assembly-redirects-with-nuget

Rune
  • 815
  • 6
  • 17
  • 1
    When using that command, I found it to be a little more involved than that. I actually answered a question a while back and suggested how to use it, complete with steps, if you're interested: https://stackoverflow.com/a/56102381/729541 – John H Sep 24 '20 at 13:36