What is the purpose of machine.config file in .NET?

Machine.config file is a machine level configuration file that is installed automatically during Visual Studio .NET installation. Only one machine.config exists for a computer. Settings defined in this file apply to the entire machine. However you can define more specific application level settings in web.config file.



Your application will first access the settings in web.config file and if any specific setting is not available in web.config file then it will use the settings defined in machine.config file. Here is a sample structure of web.config file:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<configSections>
<section name="connectionStrings"
type="System.Configuration.ConnectionStringsSection, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" requirePermission="false"/>
</configSections>
<runtime/>
<connectionStrings>
<add name="LocalSqlServer" connectionString="data source= .\SQLEXPRESS;Integrated Security=SSPI; AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.data>
<DbProviderFactories>
<add name="Odbc Data Provider" invariant="System.Data.Odbc" description Odbc" type="System.Data.Odbc.OdbcFactory, System.Data, Version=2.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089"/>
</system.data>
<system.web/>
</configuration>

This is just a sample file. Many more tags are available in machine.config file.

Related Article: Difference Between Web.Config and Machine.Config in ASP.Net

| What is the need for Bridge Pattern in C#? | What is the need for Builder Pattern in C#? | What is the need for Chain of Responsibility Pattern in C#? | What is the need for Command Pattern in C#? | What is the need for Composite Pattern in C#? | What is the need for Decorator Pattern in C#? | What is the need for Flyweight Pattern in C#? | What is the need for Interpreter Pattern in C#? | What is the need for Iterator Pattern in C#? | What is the need for Mediator Pattern in C#? | What is the need for Memento Pattern in C#? | What is the need for Prototype Pattern in C#? | What is the need for State Pattern in C#? | What is the need for Strategy Pattern in C#? | What is the need for Template Method Pattern in C#? | What is the need for unsafe code in C#? | What is the purpose of assert() in C#? | What is the purpose of AutoResetEvent in .NET? | What is the purpose of Console.ReadLine() in C#? | What is the purpose of machine.config file in .NET? |


“Amazon and the Amazon logo are trademarks of Amazon.com, Inc. or its affiliates.”

| Privacy Policy for www.dotnet-guide.com | Disclosure | Contact |

Copyright - © 2004 - 2024 - All Rights Reserved.