Simplest way to have a configuration file in a Windows Forms C# application

You want to use an App.Config. When you add a new item to a project there is something called Applications Configuration file. Add that. Then you add keys in the configuration/appsettings section Like: <configuration> <appSettings> <add key=”MyKey” value=”false”/> Access the members by doing System.Configuration.ConfigurationSettings.AppSettings[“MyKey”]; This works in .NET 2 and above.

ASP.NET web.config: configSource vs. file attributes

file attribute Specifies a relative path to an external file that contains custom application configuration settings specific to the appSettings section will merge (and override) settings in the .config file will not cause web application to restart when modifying the specified file http://msdn.microsoft.com/en-US/library/ms228154(v=vs.100).aspx Using the Configuration.AppSettings.Settings.Add API will result in all settings being merged back … Read more

Nginx 403 error: directory index of [folder] is forbidden

If you have directory indexing off, and is having this problem, it’s probably because the try_files you are using has a directory option: location / { try_files $uri $uri/ /index.html index.php; } ^ that is the issue Remove it and it should work: location / { try_files $uri /index.html index.php; } Why this happens TL;DR: … Read more

Is the buildSessionFactory() Configuration method deprecated in Hibernate?

Yes it is deprecated. Replace your SessionFactory with the following: In Hibernate 4.0, 4.1, 4.2 private static SessionFactory sessionFactory; private static ServiceRegistry serviceRegistry; public static SessionFactory createSessionFactory() { Configuration configuration = new Configuration(); configuration.configure(); ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings( configuration.getProperties()). buildServiceRegistry(); sessionFactory = configuration.buildSessionFactory(serviceRegistry); return sessionFactory; } UPDATE: In Hibernate 4.3 ServiceRegistryBuilder is deprecated. Use … Read more

How to implement a ConfigurationSection with a ConfigurationElementCollection

The previous answer is correct but I’ll give you all the code as well. Your app.config should look like this: <?xml version=”1.0″ encoding=”utf-8″ ?> <configuration> <configSections> <section name=”ServicesSection” type=”RT.Core.Config.ServiceConfigurationSection, RT.Core”/> </configSections> <ServicesSection> <Services> <add Port=”6996″ ReportType=”File” /> <add Port=”7001″ ReportType=”Other” /> </Services> </ServicesSection> </configuration> Your ServiceConfig and ServiceCollection classes remain unchanged. You need a new … Read more

Avoid web.config inheritance in child web application using inheritInChildApplications

As the commenters for the previous answer mentioned, you cannot simply add the line… <location path=”.” inheritInChildApplications=”false”> …just below <configuration>. Instead, you need to wrap the individual web.config sections for which you want to disable inheritance. For example: <!– disable inheritance for the connectionStrings section –> <location path=”.” inheritInChildApplications=”false”> <connectionStrings> </connectionStrings> </location> <!– leave inheritance … Read more