title: Error- Adding Connection string during installation C# Project.exe
body: <p>I followed this tutorial <a href="http://www.codeproject.com/Tips/446121/Adding-connection-string-during-installation" rel="nofollow">http://www.codeproject.com/Tips/446121/Adding-connection-string-during-installation</a> but getting error in installation </p>
  
  <p>Error 1001 Unable to create an instance of the ProjectName.Installer installer type --> Exception has been thrown by the target of an invocation -->Object reference not set to an instance of an object.</p>
  
  <p>my Installer.cs code:</p>
  
  <pre><code> public Installer()
          {
              InitializeComponent();
              string dataSource = "Data Source =" + Context.Parameters["DataSource"];
              string initialcatalog = "Initial Catalog=" + Context.Parameters["InitialCatalog"];
              string userid = "User ID=" + Context.Parameters["UserID"];
              string password = "Password=" + Context.Parameters["Password"];
              dataSource = dataSource + ";" + initialcatalog;
              dataSource = dataSource + ";Persist Security Info=True;"+userid+";"+password;
              MessageBox.Show("instance=" + dataSource);
              ExeConfigurationFileMap map = new ExeConfigurationFileMap();
              MessageBox.Show(Assembly.GetExecutingAssembly().Location + ".config");
              //Getting the path location 
              string configFile = string.Concat(Assembly.GetExecutingAssembly().Location, ".config");
              map.ExeConfigFilename = configFile;
              System.Configuration.Configuration config = System.Configuration.ConfigurationManager.
              OpenMappedExeConfiguration(map, System.Configuration.ConfigurationUserLevel.None);
              string connectionsection = config.ConnectionStrings.ConnectionStrings
              ["TECHNOSOFT.Properties.Settings.Tech2014ConnectionString1"].ConnectionString;
  
              ConnectionStringSettings connectionstring = null;
              if (connectionsection != null)
              {
                  config.ConnectionStrings.ConnectionStrings.Remove("TECHNOSOFT.Properties.Settings.Tech2014ConnectionString1");
                  MessageBox.Show("removing existing Connection String");
              }
  
              connectionstring = new ConnectionStringSettings("TECHNOSOFT.Properties.Settings.Tech2014ConnectionString1", dataSource);
              config.ConnectionStrings.ConnectionStrings.Add(connectionstring);
  
              config.Save(ConfigurationSaveMode.Modified, true);
              ConfigurationManager.RefreshSection("connectionStrings");
          }
  </code></pre>
  
  <p>What iam missing? Help</p>