.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Configuration Settings in c sharp

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :WPF

Hi All,

I m using c sharp and I have app.config file as follows,



xml version

View Complete Post

More Related Resource Links

Best Practice for Windows Service "Settings" (Configuration) with .Net (C#) ???

Background:   I'm developing a Windows service using C# and .Net 3.5.  The behavior of the service should be controlled by some settings.  The settings will vary per host-computer but will not vary per user (which should be understandable since the settings control behavior of a service.)  A GUI panel of sorts must be provided to set-up and modify the settings that control the service behavior.Secondly, there is a "locally installed application" that has its own settings and those settings also vary per host-computer so all users of that computer would experience the same settings.  (Seemingly analogous maybe to a connection string but not a connection string.)Note that I do NOT perceive any need for Click-once support, web support, and so forth.  Translation:  I think I need the simplest darn type of settings support, the old "dinosaur" level of requirements not much more sophisticated than INI files used to be. I've researched using the "built-in" settings that make use of the Settings Visual Designer in VS 2008 and  System.Configuration.ApplicationSettingsBase.  It seems that: 1.  Application Settings cannot be changed at runtime.  MSFT documentation indicates the software must be shut down and settings must be modified by patching the XML with a text editor (notepad et al.)  The framework specifically prohibits application settings from being

How launched EXE use it's own configuration settings? (Reflection)


Hi All,

I am using reflection to run an EXE file from my application.

But the Launched EXE using the appsettings of my application.

How it'll use the configuration settings from EXE configuration file.

Thanks in advance.

System.net proxy configuration settings


Hi there

I need to access external links from my application and i cant configure the proxy settings on my app.config.

My situation is this:

My machine is connected to a domain but im am logged to my machine with a local user(outside the domain).

My IE8 has the proxy settings configured and they require a username/password.

How can i tell my app to use the username\password required by the proxy to authenticate?



Excluding Files From Different Configuration Settings


Hey dudes,

Does anyone know how I can exclude certain folders and files from certain builds? Essentially I've got test code that needs to be deployed to the testing server - but obviously not the real server. This is in both files and folders.

Using the configuration manager profiles, I would like to create a profile for each scenario, and tell it what files it does not need.


Problem in reading WCF configuration settings



The great thing about WCF is that you can configure you're WCF bindings in a configuration file and not through code.
We are now making connection to WCF's webservices in our SharePoint code, but now the question is where to place the WCF configuration settings. 


For deployment reasons we don't want to place the settings in the SharePoint web.config:

-  can't be easily changed by admin users through SharePoint Gui

-  new deployment needed to change configuration settings

-  webservices u

Analysis Services Project under VS2008 not honoring Configuration Settings ?

I have a solution with SSRS and SSAS projects in it. Since we have 3 different environments I use VS Configurations for the individual settings. In each of these environments different groups have access to these cubes. However if I deploy the project the roles on the instances are always overwritten by the settings defined in the project. And it seems it is not possible to have different role settings that for each VS configuration. Am I missing something, it should somehow be possible to use the VS configurations to have different permissions per deployment environment?!

Backup SharePoint 2010 farm configuration settings only get an error for not enough disk space when



I am trying to do a backup the Backup using the Backup and Restore feature in SharePoint 2010 Central Administration.  I just want to backup only the farm configuration settings only.

so I followed the GUI 

Open CA Backup and Restore, checked the Farm checkbox,  click Next 

I chose the following:

Backup Type :  Full

Data to backup:  Back up only configuration settings

Backup File location  :   use an UNC shared location   \\servername\sharedname

at this point,  I see the Estimated disk space required is:   1.2 GB 

the server hard disk available space is  30 GB

but when i click the Start Backup,  i got an error in RED saying "There is not enough disk space. Free additional space on your hard disk and then try again. Approximate amount of space needed is 40 GB.   Amount of space free on disk:  30 GB."

Why is this happened?  and the estimated disk spaced required still showed at 1.2GB

If anyone had experience this problem and have a solution, please advice









Reading configuration settings from service installer



not sure if this is the correct forum but anyway: I have a windows service and I am using the default settings stored in configuration file, like myservice.exe.config. Everything works fine when the service runs, but when I want to install or uninstall it via the installutil, the settings stored in myservice.exe.config are not read.  I guess this is because the installutil is the application being run, and loading my service assembly via reflection does not cause its configuration file to be read. Okay, but how can I do that? How can I cause the settings stored in app configuration file to be loaded during the installation phase of the service?



Convert English to Arabic number without changing any regional settings in .net

Well, most applications that I worked with was multilingual that supports English UI and Arabic UI.

And one of the major issue that we have faced is displaying Arabic numbers without the need of changing the regional settings of the PC.

So the code below will help you to display Arabic number without changing any regional settings.

validateRequest appears to be kicking in in MVC RC1 despite settings

After upgrading a project to the RC a System.Web.HttpRequestValidationException is thrown when posting a value containing HTML from a TextArea. I have checked that validateRequest=false in Views/web.config, and have set this in the application's root web.config. I have also created a fresh MVC project, created a simple view & controller and posted a simple html paragraph element with the same result. Call stack provided. [HttpRequestValidationException (0x80004005): A potentially dangerous Request.Form value was detected from the client (html="

hello world

").] System.Web.HttpRequest.ValidateString(String s, String valueName, String collectionName) +8718538 System.Web.HttpRequest.ValidateNameValueCollection(NameValueCollection nvc, String collectionName) +111 System.Web.HttpRequest.get_Form() +129 System.Web.HttpRequestWrapper.get_Form() +11 System.Web.Mvc.ValueProviderDictionary.PopulateDictionary() +113 System.Web.Mvc.ValueProviderDictionary..ctor(ControllerContext controllerContext) +74 System.Web.Mvc.ControllerBase.get_ValueProvider() +31 System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ControllerContext controllerContext, ParameterDescriptor parameterDescriptor) +53 System.Web.Mvc.ControllerActionInvoker.GetParameterValues(ControllerContext controllerContext, ActionDescriptor actionDescriptor) +109 System.W

ASP.NET Configuration not opening


I recently upgraded to VS 2010 and downgraded to SQL Server 2005. Now when I go Website > ASP.NET Configuration nothing happens.

It's likely this has to do with the fact that when I was installing SQL Server I got the 'ASP.net Version Registration requirement' warning, as well as the 'Failed to find the ASP.net Version Registration requirement with MS IIS'.

Anyone know what I need to get ASP.NET Configuration working?

An endpoint configuration section for contract 'xxx' could not be loaded because more than one end



I'm trying to test calling a webservice, I've found several free ones on http://webserviceshare.com, but none of them work for me.  Some of them give example calling code in C# which I've translated to VB.NET, they're typically just two to four lines, I don't think I've translated them incorrectly.

On that I've tried is US Zip Validator.  I added a Service Reference to http://www.webservicemart.com/uszip.asmx?WSDL, called ZipService.

I then call it like so:

            Dim myZipService As ZipService.USZipSoapClient = New ZipService.USZipSoapClient()
            Dim myCity As String = myZipService.ValidateZip("27707")

I get the following error on the first line of code:

"An endpoint configuration section for contract 'ZipService.USZipSoap' could not be loaded because more than one endpoint configuration for that contract was found. Please indicate the preferred endpoint configuration section by name."

A page with information on this web service (including C# source code) is at:


Web Deployment with IIS settings of remote server


Im trying to deploy a web application project (VS 2010) via team build (TFS 2010), i got to use IIS settings of development server for deployment. So from the project properties I configured the web projects to use Custom web server, (enabled radio button), once i do this the Option in the tab Package/Publish Web "Include all IIS Settings as configured in IIS manager" gets disabled and as a result the deployed web project does not have this IIS settings.

What am I missing here, Im not using the option "Use local IIS Web Server" because the build happens in a build server and would try to take local IIS settings for packaging which is not present.

If this is not possible, suggest me any workaround. Any help on this is greatly appreciated.

Trim function in C Sharp

How do i use "trim" function in C Sharp? I have a string and i want to strip off spaces from the end of the string. Any idea how do i do it??


Patterns in Practice: Convention Over Configuration


We look at some techniques you can adopt to reduce the amount of housekeeping code you write so you can focus on the essence of the application.

Jeremy Miller

MSDN Magazine February 2009

Test Run: Configuration Testing With Virtual Server, Part 2


Because Virtual Server is built upon a set of COM modules, you can automate the creation and testing of virtual machines. Here we use Windows PowerShell to run the tests.

Dr. James McCaffrey and Paul Despe

MSDN Magazine December 2008

Test Run: Configuration Testing With Virtual Server, Part 1


This time James McCaffrey sets up a virtual environment to use for configuration testing to introduce you to software configuration testing with Microsoft Virtual Server

Dr. James McCaffrey

MSDN Magazine September 2008

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend