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 n开发者_运维百科ot get defined. The application's .exe.config file is there in the release folder along with the .exe file and is up to date.
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.
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
精彩评论