Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

app.config and 64-bit machines

I have an app that works fine on 32-bit systems, but fails on XP 64 bit systems. I've tracked it down to the connection string defined in my app.config thus:

  <connectionStrings>
    <clear/>
    <add name="IFDSConnectionString" 
        connectionString="Data Source=fdsdata;Initial Catalog=IFDS;
        Trusted_Connection=true;Connect Timeout=0"
        providerName="System.Data.SqlClient" />
  </connectionStrings>

When I try to reference it in code, I find that the ConfigurationManager.ConnectionStrings collection only contains the LocalSqlServer connection string from the machine.config file and not my custom string.

Another oddity is that it works fine when I run the app out of Visual Studio. It is only when I run out of the release folder that the connection string does not get defined. The application's .exe.config file is there in the release folder along with the .exe file and is up to date.

like image 483
Dale Lutes Avatar asked May 28 '10 16:05

Dale Lutes


People also ask

What is a 64-bit application?

Essentially, 64 bits allows for numbers as high as 18 quintillion, meaning that a computer can calculate more, faster. That's a simplistic way of explaining this, but another way of looking at this is that with 64-bit computer, a processor can use—hold on to your hats—16 exabytes of memory.

What is app config?

App. Config is an XML file that is used as a configuration file for your application. In other words, you store inside it any setting that you may want to change without having to change code (and recompiling). It is often used to store connection strings.

What is the difference between app config and web config?

config is parsed at runtime, so if you edit the web. config file, the web application will automatically load the changes in the config file. Â app. config is parsed at compile time, so if you edit the app.

How do I change my Visual Studio application from 32-bit to 64-bit?

Open the 32-bit project in Visual Studio 2008. In the file menu, click Build and select Configuration Manager. Pull down the drop-down under “Active solution platform” which currently displays “Win32” and select New. In the drop-down for “Type or select the new platform”, select “x64”.


2 Answers

I eventually found the explanation here: http://social.msdn.microsoft.com/forums/en-US/clr/thread/c25cd2c0-653d-4890-97b8-d2c9ceda2949/

In short, this behavior occurs when a manifest file for the application is used. In that case, the framework looks for application_name.config, NOT application_name.exe.config. One workaround is to rename the config file after building the app. Another is to add the assemblyIdentity node to the manifest. In my own case, I was able to simply delete the manifest file and life is good once again.

like image 188
Dale Lutes Avatar answered Oct 26 '22 23:10

Dale Lutes


Add the connection string to devenv.exe.config file.

This is located

Visual Studio 2010

$$InstallLocation$$\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe.config

Visual Studio 2008

$$InstallLocation$$\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe.config

like image 27
Michael Grassman Avatar answered Oct 27 '22 01:10

Michael Grassman