How to enable configSource attribute for Custom Configuration Section in .NET?

The actual file, must be placed relative to the project output folder (by default “\bin\debug” or “bin\Release” Also, The file in your project tree, look at the properties of the file, and make sure the “Copy to Output Directory” setting is set to “Copy Always” or “Copy if Newer” EDIT: make sure the separate config … Read more

Hadoop: …be replicated to 0 nodes instead of minReplication (=1). There are 1 datanode(s) running and no node(s) are excluded in this operation

This error is caused by the block replication system of HDFS since it could not manage to make any copies of a specific block within the focused file. Common reasons of that: Only a NameNode instance is running and it’s not in safe-mode There is no DataNode instances up and running, or some are dead. … Read more

Read custom configuration file in C# (Framework 4.0)

// Map the roaming configuration file. This // enables the application to access // the configuration file using the // System.Configuration.Configuration class ExeConfigurationFileMap configFileMap = new ExeConfigurationFileMap(); configFileMap.ExeConfigFilename = roamingConfig.FilePath; // Get the mapped configuration file. Configuration config = ConfigurationManager.OpenMappedExeConfiguration( configFileMap, ConfigurationUserLevel.None); from http://msdn.microsoft.com/en-us/library/system.configuration.configurationmanager.aspx

How do I set CultureInfo.CurrentCulture from an App.Config file?

I don’t know a built-in way to set it from App.config, but you could just define a key in your App.config like this <configuration> <appSettings> <add key=”DefaultCulture” value=”pt-BR” /> </appSettings> </configuration> and in your application read that value and set the culture CultureInfo culture = new CultureInfo(ConfigurationManager.AppSettings[“DefaultCulture”]); Thread.CurrentThread.CurrentCulture = culture; Thread.CurrentThread.CurrentUICulture = culture; Also, as … Read more

getServletConfigClasses() vs getRootConfigClasses() when extending AbstractAnnotationConfigDispatcherServletInitializer

A Bit on ApplicationContext Hierarchies Spring’s ApplicationContext provides the capability of loading multiple (hierarchical) contexts, allowing each to be focused on one particular layer, such as the web layer of an application or middle-tier services. One of the canonical examples of using hierarchical ApplicationContext is when we have multiple DispatcherServlets in a web application and … Read more

Can .NET load and parse a properties file equivalent to Java Properties class?

No there is no built-in support for this. You have to make your own “INIFileReader”. Maybe something like this? var data = new Dictionary<string, string>(); foreach (var row in File.ReadAllLines(PATH_TO_FILE)) data.Add(row.Split(‘=’)[0], string.Join(“=”,row.Split(‘=’).Skip(1).ToArray())); Console.WriteLine(data[“ServerName”]); Edit: Updated to reflect Paul’s comment.

Log4Net config in external file does not work

Do you have the following attribute in your AssemblyInfo.cs file: [assembly: log4net.Config.XmlConfigurator(ConfigFile = “Log4Net.config”, Watch = true)] and code like this at the start of each class that requires logging functionality: private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); I have a blog post containing this and other info here.