Problem in setup project [modified]
-
Hi All I am adding app.config file in application folder of setup project for creating installer. after installing application when we run it ..if gives following error
The Key ConnectionString does not exist in the app setting configuration section
but when I run application in Dotnet.it runs fine but when run after installing then there is above error occurs here is app.config file
<configuration>
<appSettings>
<add key="ConnectionString" value="data source=localhost\sqlexpress;initial catalog=SFM;integrated security=SSPI;persist security info=False;packet size=4096" />
</appSettings>
</configuration>Thankz in Advance Regards Kashif :rose::rose::rose::rose:
modified on Monday, September 7, 2009 6:05 AM
Unless I misunderstand the error is correct:
The Key ConnectionString does not exist in the app setting configuration section
as in
<add key="Main.ConnectionString" value="...
the key is "Main.ConnectionString" Hope this give you the answer you need!
-
Unless I misunderstand the error is correct:
The Key ConnectionString does not exist in the app setting configuration section
as in
<add key="Main.ConnectionString" value="...
the key is "Main.ConnectionString" Hope this give you the answer you need!
First of all thankz for your reply Sorry keefb it is my written mistake in question .......In project I am using same key .........now I corrected my question ...please check it again ......In app.config the key is ConnectionString .........and I also use ConnectionString (Same variable) in Code file ............Now please check it and can you tell me where is problem .... why error occurs that I mentioned in first post :-O
-
First of all thankz for your reply Sorry keefb it is my written mistake in question .......In project I am using same key .........now I corrected my question ...please check it again ......In app.config the key is ConnectionString .........and I also use ConnectionString (Same variable) in Code file ............Now please check it and can you tell me where is problem .... why error occurs that I mentioned in first post :-O
Can you post the code that gets the connection string?
-
Can you post the code that gets the connection string?
Here is code
public clsGeneric()//Constructor
{
_mainConnection = new SqlConnection();
AppSettingsReader _configReader = new AppSettingsReader();\_mainConnection.ConnectionString = \_configReader.GetValue("ConnectionString ", typeof(string)).ToString(); }
When I run project from visual studion it run fine......but when I create installer and install application then run from installed exe then error occurs
-
Here is code
public clsGeneric()//Constructor
{
_mainConnection = new SqlConnection();
AppSettingsReader _configReader = new AppSettingsReader();\_mainConnection.ConnectionString = \_configReader.GetValue("ConnectionString ", typeof(string)).ToString(); }
When I run project from visual studion it run fine......but when I create installer and install application then run from installed exe then error occurs
Is there an
app.config
or_yourapplicationname_.exe.config
in the installation folder? -
Is there an
app.config
or_yourapplicationname_.exe.config
in the installation folder? -
Here is code
public clsGeneric()//Constructor
{
_mainConnection = new SqlConnection();
AppSettingsReader _configReader = new AppSettingsReader();\_mainConnection.ConnectionString = \_configReader.GetValue("ConnectionString ", typeof(string)).ToString(); }
When I run project from visual studion it run fine......but when I create installer and install application then run from installed exe then error occurs
Why do you not use
ConfigurationManager.AppSettings["ConnectionString"].Value.ToString()
instead? Moreover, why do you store your connection string as an appsetting, and not as connectionString in your app.config?var question = (_2b || !(_2b));
-
There is the problem. Say your application builds to an exe called
Foo.exe
, it expects the app config file to be namedFoo.exe.config
, notapp.config
. So you can't just copy the app.config into the installer directly. Make sure the Installer project has "Primary output from your project name here (Active)" in it. As long as the app.config exists in the source project it should be installed with the correct name. Also Greg Chelstowski's post is correct, you should consider using aConnectionString
element in your app.config rather than adding the connection string as an app setting. -
There is the problem. Say your application builds to an exe called
Foo.exe
, it expects the app config file to be namedFoo.exe.config
, notapp.config
. So you can't just copy the app.config into the installer directly. Make sure the Installer project has "Primary output from your project name here (Active)" in it. As long as the app.config exists in the source project it should be installed with the correct name. Also Greg Chelstowski's post is correct, you should consider using aConnectionString
element in your app.config rather than adding the connection string as an app setting. -
Why do you not use
ConfigurationManager.AppSettings["ConnectionString"].Value.ToString()
instead? Moreover, why do you store your connection string as an appsetting, and not as connectionString in your app.config?var question = (_2b || !(_2b));