Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting 64 bit version of machine.config

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
like image 535
Lareau Avatar asked Nov 13 '22 23:11

Lareau


1 Answers

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.

like image 156
Adam Gritt Avatar answered Dec 19 '22 08:12

Adam Gritt