'Saving Settings to Executable VB.Net

I have read allot of posts on saving settings but none actually get to the heart of what I'm trying to do. I have created a configuration application for a 3rd party application the settings of which need to change from site to site. I'm trying to find a way to store these settings inside the executable without having to compile hard coded settings into it. this will let the end user edit the settings if for instance they need to change a name or IP address in the program.

I need to keep the executable as an EXE only downloadable application, all of the solutions I can find consist of external files that won't be downloadable. Is this even possible?



Solution 1:[1]

I don't believe .Net will allow you to do it exactly the way you want. While running, the .Exe will be locked for write access. Even if it weren't, the .Net runtime validates the IL signature before just-in-time compiling, and I expect this would break that validating.

It's sad. I've often wished for the same ability. Just let me append my data to the end of the .exe! But it's just not something Windows supports.

Instead, have the program create a settings file on first run. This file can live in the %AppData% special folder, so if the user downloads the .exe and saves it to their desktop, there won't be an unexplained file there.

Solution 2:[2]

Use registry setting.

This does not require you to include another file and it saves the setting per user.

But, you must create a section of your application for changing the configuration. The user should NOT edit the registry directly but you should provide an interface within your application that allows them to view/edit the changes.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Steve