How do I get intellisense in app.config for a custom section?

XML Intellisense will not automatically work for a custom configuration section. Visual Studio may report warnings on compilation complaining that the attributes of the custom configuration section are not defined. These warnings may be ignored. If you want XML IntelliSense support for a custom configuration section (or if you just want the ‘schema not found’ … Read more

Custom app.config Config Section Handler

First you add a property in the class that extends Section: [ConfigurationProperty(“pages”, IsDefaultCollection = false)] [ConfigurationCollection(typeof(PageCollection), AddItemName = “add”)] public PageCollection Pages { get { return (PageCollection) this[“pages”]; } } Then you need to make a PageCollection class. All the examples I’ve seen are pretty much identical so just copy this one and rename “NamedService” … Read more

Is reading app.config expensive?

I’m sure that all configuration files(web.config or app.config) are cached by default, so you don’t need to create a static class that holds all values or be afraid that the files are accessed permanently. Here is some reading: Web.Config is Cached ConfigurationManager.RefreshSection Method Application Configuration Files Explained ASP.NET Configuration Overview Regarding to your requirement to … Read more

web.config and app.config machine-specific settings in git

I’d like to suggest you look at ConfigGen. We use it in all our projects, and it works wonders for all the developers and also for all our environments. It basically runs off a spreadsheet that states machine name and output configuration file, and then tokenises a template App.Config or Web.Config, substituting values from the … Read more

MSTest and app.config issue

Kateroh, My setup looks like this (I’m using msbuild from a TFSbuild.proj): Build sln Copy all from output to %TEMP% (black magic :D) Don’t know why but mstest is looking for references in %TEMP%. Run mstest with parms: “C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe” /nologo /testcontainer:$(TestDir)\mylib.dll /resultsfile:$(TestResultFile) /runconfig:$(SlnDir)\AutomaticBuildTest.testrunconfig /searchpathroot:$(TestDir) /publish:mytfsserver /publishbuild:$(BuildDefinition) /flavor:Debug /platform:AnyCPU /teamproject:mytfsproject where AutomaticBuildTest.testrunconfig … Read more

exePath must be specified when not running inside a stand alone exe

You need to use a different configuration manager in a web context. The following code block shows an example of how to deal with this: System.Configuration.Configuration configuration = null; if (System.Web.HttpContext.Current != null) { configuration = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(“~”); } else { configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); }

How to store a collection of custom objects to an user.config file?

The way to add custom config (if you require more than just simple types) is to use a ConfigurationSection, within that for the schema you defined you need a ConfigurationElementCollection (set as default collection with no name), which contains a ConfigurationElement, as follows: public class UserElement : ConfigurationElement { [ConfigurationProperty( “firstName”, IsRequired = true )] … Read more

tech