5

I'm feeling stupid.

I've just created my first ASP.net 4.0 site after working my way though over the years from 1.1 upwards. We have several settings at the machine.config level that I need to migrate to the new 4.0 machine.config. I though I had be adding the required connection strings to the connection string section of the following two files:

  1. C:\Windows\Microsoft.NET\Framework64\v4.0.30319\machine.config
  2. C:\Windows\Microsoft.NET\Framework\v4.0.30319\machine.config

When I created a new website in IIS and assigned it to the ASP.net 4.0 Application pool I only get the default LocalSqlServer connection string. I tried editing the name of this in the two files above to indicate which file it was in, but there was no change.

Are there machine.config files in other locations I should be looking at?

Jon P
  • 19,442
  • 8
  • 49
  • 72

2 Answers2

9

Due to the wonders of microsoft putting the machine.config a few location the locations I actually wanted was:

C:\Windows\Microsoft.NET\Framework64\v4.0.3031\CONFIG\machine.config

C:\Windows\Microsoft.NET\Framework\v4.0.30319\CONFIG\machine.config

Jon P
  • 19,442
  • 8
  • 49
  • 72
0

I had the same issue. I did't realize that my ConfigurationManager.ConnectionStrings["ConnectionNameWhateverItIs"].ConnectionString was looking at the Framework64 location. You can put the following line in your code to get location of the Machine Config file being used:

string connString = ConfigurationManager.OpenMachineConfiguration().ConnectionStrings.CurrentConfiguration.FilePath;
John
  • 214
  • 3
  • 14