I am currently having an issue with removing the app.config file from my project.
I wish to have a single .exe file, however, every time I delete the app.config the program will not run.
Does anyone know of a solution to prevent the application from trying to find a app.config file?
Thanks
Related
I am making setup file for outlook add-in.
Everything working fine but I am not able to read connection string or any key in app.config file after install add-in.
I am making setup reference from https://blogs.msdn.microsoft.com/mcsuksoldev/2010/10/01/building-and-deploying-an-outlook-2010-add-in-part-2-of-2/
What I noticed :
“Manifest” – set this to “[TARGETDIR]MyOutlookAddIn.vsto|vstolocal”.
If I use above values for Manifest that time not able to read app.config
“Manifest” – set this to “[TARGETDIR]MyOutlookAddIn.vsto”.
In this case, I am able to read app.config file but two times install add-in
Without setup, I am able to read app.config file.
My Question is.
Why I am not able to read app.config file after install add-in? What is the solution for this?
I have a question about recompiling different components of C# console app after making changes
Program.cs --> needs to be rebuilt to see changes
App.config --Not sure
Also i have a folder called UserFiles which has a csv file that I refer in my Program.cs file. If I make changes to either App.config or csv file should I recompile the program. Can someone explain to me how this works please?
Thanks
R
Correct
The App.config file is essentially just a XML file that your program can read settings from when it runs. You don't need to recompile if you make changes to that.
No. Your CSV has absolutely nothing to do with the compilation of your program
Previously sorry for my English...
I want to store connection string in app.config
Does my application need app.config file after it have build
I've tried to delete app.config and then ran application from the release folder but no errors appeared, but when from the debug folder i have got one.
So where app.config's keys embed in application?
By default, when you build; the app.config is renamed to <YourAssembly>.exe.config and copied to the output directory.
This is why it works even if you deleted app.config - the old .config is still in the output directory. Try looking in that directory for a .config file.
I am making one windows application in c# in where i added one file as app.config file.I have written some code in that file as
<appSettings>
<add key ="FlagForArchiving" value="true"/>
</appSettings>
In 'program.cs' file i am reading this value as
ConfigurationSettings.AppSettings["FlagForArchiving"].ToString();
On local machine i can retrieve value from config file but whenever i am building that application and running on any other machine then I cant read the value from config file.I am trying to run my application on windows 7.Please help me.Thanks in advance.
app.config is renamed to <MyProgramName>.exe.config when you build. When your program runs it will look for that <MyProgramName>.exe.config file, not app.config.
You need to deploy the renamed file (<MyProgramName>.exe.config) along with your program.
In your case, you need to copy over OBViewer.exe, OBViewer.exe.config, and any other files that OBViewer.exe depends on (e.g. other .dll assemblies in your debug/release directory).
By the way, this renamed file is often commonly referred to as "app.config", even if it doesn't have the same filename.
and the app.config file exists on the other machine?
Before reading check if it exists
The exception you get says whats incorrect: "FileNotFoundException"
EDIT
here is the correct way!
if (File.Exists(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile))
{
MessageBox.Show(ConfigurationSettings.AppSettings["FlagForArchiving"].ToString());
}
I've developed a windows service application using Visual Studio 2008 / C#.
I have an app.config file in the project. When installed, the app.exe.config file appears beside the executable but it appears not to be reading the values from it when I try to access them through ConfigurationManager.AppSettings.
Has it copied the config file elsewhere or is there some other problem I don't know about?
Thanks in advance,
Martin.
Edit:
The config file name is infact my_exe_file_name.exe.config, it looks like:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="RuntimeFrequency" value="3" />
</appSettings>
</configuration>
and I am trying to read via:
ConfigurationManager.AppSettings["RuntimeFrequency"]
The debug value I continually see is '1' and not '3'. Am I doing something wrong here?
I located the error and it was related to file permissions. After installing the service, my local user account didn't have access to modify the app.exe.config file.
The tool I was using to edit was not informing me it was being denied access to save the file - that's notepad++ if anyone is interested - so I couldn't see that it wasn't saving over the old config file.
Solved now, thanks everyone.
Martin.
When you are in debug mode check and see what settings are in the my_exe_file_name.vshost.exe.config Also make sure you adjust this in the app.config file. Visual studio should update the final config file in your bin/debug folders.
Maybe you are updating the wrong config file. You should double check that using
System.Configuration.ConfigurationManager.OpenExeConfiguration(PATH_TO_CONFIG);
Generally for the Windows Services that I write, i drop the appName.exe.config file into C:\WINDOWS\system32\
Perhaps you have an older version in that directory, which is where your service is getting the value, even though you've updated the config file in your project.
App.config file should be renamed to your_exe_file_name.exe.config and placed near the exe file.
Is it possible that you have more than one instance of the RuntimeFrequency entry defined? The ConfigurationManager reads the file from top to bottom and processes each setting individually. Therefore, the last value of RuntimeFrequency that is defined in the file is the one it will use.
If you want to know for sure if your file is being used, I would simply remove or comment out any definition for RuntimeFrequency (copy/paste errors do happen) and wait to see an application error when ConfigurationManager attempts to reference an entry in AppSettings that does not exist.