Click here to Skip to main content
15,893,644 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a Console project that will be ran in windows task scheduler. I have a property in the settings area which has the connection string of my program. How would I be able to change it even after the program is published?

I was thinking of having an xml document that has the connection string to my database. So they have the flexibility to change the location of the database anytime.

Also my project references a class library I made in my project. Will I need to bring that dll with my project or does it do it automatically?
Posted

You should be able to change them then save the changes with Properties.Settings.Default.Save

You could also pass it in as a command line argument. And you do need the dll with the application, but VS should copy it to wherever you compile the program to.
 
Share this answer
 
Maybe I am not understanding the question properly, but wouldnt you use the App.Config file?

To answer the second part of your question. When our program is compiled, a DLL of the class library will be created, you will have to move that DLL with your program!

EDIT: http://msdn.microsoft.com/en-us/library/ms184658%28v=vs.80%29.aspx[^] -- Just a little bit of info on the App.Config file! Have a click around to find out stuff you need to know.
 
Share this answer
 
v2
Comments
Member 8015046 22-Jul-11 14:31pm    
Oh hey it is the app.config thing I am looking for. But is this App.Config be accessible to the users after the console application has been saved? Like they can modify it anytime?
DominicZA 22-Jul-11 15:16pm    
Yes, they can!
tstoneami 26-Jan-24 19:55pm    
Hello, since this seems to be related to the situation I'm in, I thought I'd ask here before making a new post.

My app works great in Visual Studio, and I can publish successfully. I have an app.config that is read successfully, setting connection strings.

My problem/confusion. It publishes to a local folder (set in the publish dialogue), and creates a setup file. After I run this setup file, the same exe (called setup.exe) successfully runs my application. I can rename this file and it will still run. There are very few files here. It also publishes to a bin folder in another location, where the app.config and various reference files seem to live.

My goal: I want to distribute this application on a server in multiple locations (various customers), where I can change the app.config settings to point to different databases. The app doesn't seem to run without running setup first. How can I distribute this application as needed? I was able to write the app, but can't share it out!

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