Click here to Skip to main content
15,905,073 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Thanks in advance for any help. This is what happened, when I changes the value in app.config after I had published the application, I can see that the value is being updated. However, when I copied the application (without the myproject.exe.config) to some other location in my laptop. The value is not being updated (still the same value as those being published).

To make things simpler, allow me to provide an example:

when it is published- value for username = admin

then I went to change the value for username to administrator

if the application is run with myproject.exe.config in the same folder location, it will take the new username (administrator)

However, if the application is run without myproject.exe.config, in other words, only the application remain in that folder, it will take the old username(admin)

How can I make it such that even if the myproject.exe.config is not in that directory, the application will still take the latest value?
Posted
Updated 7-Dec-15 16:27pm
v3

1 solution

well ... the build process does this

*.cs (etc) (from your project) + app.config = your project.exe and your project.exe.config

So I would be deploying 'your project.exe.config' not app.config

you dont post any code about how you update the config with the new value - but as long as 'your project.exe.config' is in the same directory as 'your project.exe' you should be able to manually edit (eg notepad, notepad++) 'your project.exe.config' and see the change
 
Share this answer
 
v2
Comments
Eilson Tang 7-Dec-15 22:27pm    
I am sorry, I posted a bit wrong and have edited, what I meant was that if I were to updated myproject.exe.config and run the project.exe without the config file in the same directory, is there a way for me to get the updated value that I had made in the config file?
Garth J Lancaster 7-Dec-15 22:36pm    
well, Im still confused why you wont deploy myproject.exe.config to the correct place - where myproject.exe is actually located .. you can do this I guess

AppDomain.CurrentDomain.SetData ("APP_CONFIG_FILE", "path to config file")

there's a useful discussion here that might help you http://stackoverflow.com/questions/1838619/relocating-app-config-file-to-a-custom-path
Eilson Tang 7-Dec-15 22:46pm    
The reason why I want to copy myproject.exe.config out to another directory after I had published is because I want to test if the value is really stored in the application.

I had actually tested this, when I had published, myproject.exe will contain the correct username and password even if myproject.exe did not locate to myproject.exe.config, but let's say I had change my username or password to something else, I would want these value to get updated to the published application automatically, perhaps using some coding.

However, it seems like once it is not in the same directory as myproject.exe.config, the value will not get updated. Thus, I am actually thinking of a way to let the value getting stored in the application without referring to anything.

Thanks for any assistance
Garth J Lancaster 7-Dec-15 23:04pm    
why dont you encrypt the relevant section(s) of the myproject.exe.config file - thats the way its normally done, not all the deleting the config file ... plenty of links, here's a good discussion for instance http://stackoverflow.com/questions/1838619/relocating-app-config-file-to-a-custom-path
Eilson Tang 8-Dec-15 20:27pm    
sounds great, thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900