5

Right now, I'm calling the following line

System.Configuration.Configuration cnf = ConfigurationManager.OpenMachineConfiguration();

the result is the following cnf.FilePath == C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config

I get the following result on a 32bit 2003 server and a 64 bit 2008 R2 server. Ideally I would like to return the 64bit folder when installed on a 64bit server.

aka - C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config

Is there a way to get the 64 bit version without resorting to doing ConfigurationFileMaps - such as Configuration examples from Msdn

Update for comment

  • Right now, the platform setting is set to Any Cpu
  • I'm running the code in an class that inherits from System.Configuration.Install.Installer of a standard application
  • This project where the code is situated is being run as a custom action in a Visual Studio Installer setup project
Lareau
  • 1,982
  • 1
  • 26
  • 47
  • 1
    What do you have the "Platform target" set to in your project settings? – Adam Gritt May 13 '11 at 14:00
  • Updated the ticket with your answer - it's set to any platform. – Lareau May 13 '11 at 14:30
  • 2
    Is this a standard application or a web application? If it is a web application what is the Application Pool's "Enable 32-Bit Applications" setting? – Adam Gritt May 13 '11 at 14:32
  • I'm running the code in an class that inherits from System.Configuration.Install.Installer of a standard application. – Lareau May 13 '11 at 14:41
  • 1
    Is this being included as part of an install application or running via the InstallUtil.exe? – Adam Gritt May 13 '11 at 14:47
  • This project where the code is situated is being run as a custom action in a Visual Studio Installer setup project – Lareau May 13 '11 at 14:52

1 Answers1

1

Based on the above answers, I created a Visual Studio Installer. It would appear that the installer runs as a 32-bit process by default. As such any .NET code you have running as the custom Installer action would be running as 32-bit which is why you are only seeing the 32-bit Machine.Config and not the 64-bit version. This MSDN Article explains how to create the installer as a 64-bit installer. A 32-bit installer can install 64-bit items however, a 64-bit installer can only install on a 64-bit OS. You may need to have two installers created (32-bit and 64-bit) and then have the users use the appropriate version if you want to keep it simple. After I made the change to the TargetPlatform for the installer it showed up in TaskManager as a 64-bit process.

Adam Gritt
  • 2,654
  • 18
  • 20
  • Thanks for figuring this out. Since I need it for older servers, I'll probably start playing with some path string (aka framework to framework64) and try the ConfigurationFileMap. – Lareau May 13 '11 at 15:05