Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Problem in setup project [modified]

Problem in setup project [modified]

Scheduled Pinned Locked Moved C#
helpworkspacecsharpsecurity
11 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X xodeblack

    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

    K Offline
    K Offline
    Keith Barrow
    wrote on last edited by
    #2

    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!

    X 1 Reply Last reply
    0
    • K Keith Barrow

      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!

      X Offline
      X Offline
      xodeblack
      wrote on last edited by
      #3

      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

      K 1 Reply Last reply
      0
      • X xodeblack

        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

        K Offline
        K Offline
        Keith Barrow
        wrote on last edited by
        #4

        Can you post the code that gets the connection string?

        X 1 Reply Last reply
        0
        • K Keith Barrow

          Can you post the code that gets the connection string?

          X Offline
          X Offline
          xodeblack
          wrote on last edited by
          #5

          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

          K G 2 Replies Last reply
          0
          • X xodeblack

            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

            K Offline
            K Offline
            Keith Barrow
            wrote on last edited by
            #6

            Is there an app.config or _yourapplicationname_.exe.config in the installation folder?

            X 1 Reply Last reply
            0
            • K Keith Barrow

              Is there an app.config or _yourapplicationname_.exe.config in the installation folder?

              X Offline
              X Offline
              xodeblack
              wrote on last edited by
              #7

              app.Config. I added this file in application folder of setup project

              K 1 Reply Last reply
              0
              • X xodeblack

                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

                G Offline
                G Offline
                Greg Chelstowski
                wrote on last edited by
                #8

                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));

                X 1 Reply Last reply
                0
                • X xodeblack

                  app.Config. I added this file in application folder of setup project

                  K Offline
                  K Offline
                  Keith Barrow
                  wrote on last edited by
                  #9

                  There is the problem. Say your application builds to an exe called Foo.exe, it expects the app config file to be named Foo.exe.config, not app.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 a ConnectionString element in your app.config rather than adding the connection string as an app setting.

                  X 1 Reply Last reply
                  0
                  • K Keith Barrow

                    There is the problem. Say your application builds to an exe called Foo.exe, it expects the app config file to be named Foo.exe.config, not app.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 a ConnectionString element in your app.config rather than adding the connection string as an app setting.

                    X Offline
                    X Offline
                    xodeblack
                    wrote on last edited by
                    #10

                    Hi keefb very Thankz Problem is fix

                    1 Reply Last reply
                    0
                    • G Greg Chelstowski

                      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));

                      X Offline
                      X Offline
                      xodeblack
                      wrote on last edited by
                      #11

                      Thankz Greg Chelstowski I change the connection string according to ur post

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups