Adding app.config (Application Configuration File) in Visual Studio Professional 2017 - c#

I can't get the Application Configuration File template to show up under my Add > New Item > Visual C#. I've run a repair. I've uninstalled and reinstalled. I've deleted and added Cache folders. I've run devenv.exe /InstallVSTemplates. Nothing is working.
If anyone can tell me specifically what installation elements I should be including, and specifically what type of Project I need to start that might help.
I want to create a simple .Net Web Form in .Net and C# and need to include an app.config file.

When you create a new project (depending on the type of project like a web application for example) it will automatically create a template app.config file.
Worst case just make a txt file in notepad and call it [Appname].config

Another way would be to go in the project properties, then the Settings tab. If there are no settings yet, a link should exist in the middle of the empty tab to create a default setting file. Add one Application or User setting and save. Among other things a config file will be created for you too.

Related

Using appname.exe.config to store externally editable settings

I have an application that is run from an application server. I want to beable to change the connection string that the application uses from outside of the application (I do not want the user to do this, and I do not want to use a command line argument, but I want to save the information without having to re-compile)
The application is .net 4.0
I notice that visual studio creates a file called appname.exec.config. Can I add a tagged entry to this file then read it from the .net (C#) application? I don't want the program to edit the file. Instead I want an administrator to edit the file and the program to read it.
I prefer not to use some custom xml file that gets packaged, perferring instead to use a file like appname.exe.config that is automatically deployed by Visual Studio.
Within Visual Studio you'll see under your project a 'Settings.settings' file. This is where things such as connection strings and other configuration info is stored. You can also add additional fields to this file. If your scope is set as 'Application' then these are settings that CANNOT be changed at runtime, which is exactly what you are looking for. Instead someone would need to open up the XML file and edit it directly to make a change for the next time your application runs.
http://msdn.microsoft.com/en-us/library/a65txexh%28v=vs.100%29.aspx

Configuration file in .net windows application

I am new in .net.
I am actually converting a Console application into Windows application in .net. And I want to include some configuration files in the windows application.
I know that for web application there is Web.config and for Console application there is App.config to have the configuration details.
But I don't have any ideas about the configuration file in windows application. I have to include the configuration details in my windows application that included in the console application that i want to convert.
UPDATE
Problem Fixed.
It is a fault from my part. I also copied startup tag. Can anyone please tell me for what this tag.??
Thant you all for the replay.
A windows application is a WinForms or WPF application and use the same App.Config renamed in yourappname.exe.config as in Console Applications. So just go on with that
An excellent series of articles on configuration files (I will dare to say the reference)
Unraveling the Mysteries of .NET 2.0 Configuration
Go to the project's properties and change to the "Settings" tab. You might see a message that no settings file is present right now. If you click the link, one will be created.
Add one setting as a dummy so that all sections in the app.config file are created (<applicationSettings> or <userSettings> and the respective section for your namespace). Then, open the original config file in a text edit, copy the settings lines (not the lines containing the <namespace.properties.settings> start and end tags) and then paste them into the new app.config. Make sure that you copy application settings to the <applicationSettings> section and user settings to the <userSettings> sections accordingly.
The next time you open the Settings tag, you'll be asked whether you'd like to import the new settings.
There’s a really simple way to do this.. simply go to the File \ Add New Item menu, or hit Ctrl+Shift+A
You’ll notice that it’s already set to App.config for you. Just hit the Open button.
If you look in the Solution Explorer, you will see that the config file is in your project:
Now build your application, and take a look in the \bin\debug\ folder. You’ll see that the configuration file has automatically been generated and named correctly for your executable:
Reference taken from HERE
Right click on your project go to -->Add --> New Item and then you will find a dialog as shown

create visual studio solution and include settings of the applicatioon

I am building a C# application. it has some parameters saved of a file named "settings.ini" .
Of course, I managed my application to read settings ,offer an interface for editing them and finally save them back to the ini file.
Would you please tell me how to include this setting file to the installation package (VS2008)
Thanks.
Instead of using an ini file, you should be using a .config file - that's the normal configuration option for .NET application with quite a lot of built in support.
You should be able to add an app.config file to your project from the new item screen in Visual Studio.
Take a look at Configuration Files on MSDN for more detail and the AppSettings class (this page includes some examples).

For a Silverlight 4 Visual Studio solution, what needs to be in version control?

I have a Silverlight 4 app that I'm building with Visual Studio 2010. I'm using Mercurial/TortoiseHG to do version control. Which files do I need to check in? By default, it checks in all sorts of .dlls in /bin/debug and stuff. Do I really need those? Or can I just grab code and content files? Do I need to version something to keep track of project properties and references, or is that contained within the .csproj file itself?
You don't need to include stuff in /bin or /obj. This is true of all VS solutions in source control. These are recreated upon every rebuild. Also, for Silverlight specifically, you don't need to check in the XAP file that is generated in the ClientBin of your web app.
From MSDN (via this social.msdn thread):
You can add the following files to Visual Studio source control:
Solution files (*.sln).
Project files, for example, *.csproj, *.vbproj files.
Application configuration files, based on XML, used to control run-time behavior of a Visual Studio project.
Files that you cannot add to source control include the following:
Solution user option files (*.suo).
Project user option files, for example, *.csproj.user, *.vbproj.user files.
Web information files, for example, *.csproj.webinfo, *.vbproj.webinfo, that control the virtual root location of a Web project.
Build output files, for example, *.dll and *.exe files.
It doesn't say anything specific about Silverlight projects though.
Is Mercurial/TortoiseHG integrated into Visual Studio? i.e. can you check out/submit from within VS?
If so, if you right click on the project name and select "Add Solution to Source Control" it should add those parts of the project that it needs ignoring everything else.

WebReference and Source Control

I have a C# application that uses several web services which were added to my project as web references. I want to know what files i should check into source control.
in my project there is a folder structure from my project directory that looks like this:
Project
Web References
WS
WS.wsdl
Reference.cs
Reference.map
...misc .datasource and .xsd files
Which of these files should i put in source control?
Thanks
Suggest keeping all those files under source control, but only for completeness for other developers using your project's source code, or having to perform a Checkout/Get Latest on any new machine (after your dev machine's hard drive dies, etc.).
Once Visual Studio builds the web reference, all those files are built and remain unchanged until you 'Refresh Web Reference'. If you modify them yourself, i.e. change a datatype, or remove an XML attribute (I've had to do that for some obscure runtime SOAP problem), then check those changes in as well.
If your nant script or visual studio solution or what have you rebuilds any particular files on each build, then don't check those in, as it'll just lead to confusion. Otherwise check it all in.

Categories