Click here to Skip to main content
15,892,643 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I've made an application, also made its setup properly.
Now i want to add custom form so that i can mention datasource name details at the time of installation.
For this i'm taking help from this link
So in the installer class i've written this
public override void Install(System.Collections.IDictionary stateSaver)
        {
            try
            {
                string dataSource = "Data Source =" + Context.Parameters["DataSource"];
                string initialcatalog = "Initial Catalog=" + Context.Parameters["InitialCatalog"];
                dataSource = dataSource + ";" + initialcatalog;
                dataSource = dataSource + ";Integrated Security=SSPI;";
                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
                ["SqlConnectionString"].ConnectionString;

                ConnectionStringSettings connectionstring = null;
                if (connectionsection != null)
                {
                    config.ConnectionStrings.ConnectionStrings.Remove("SqlConnectionString");
                    MessageBox.Show("removing existing Connection String");
                }

                connectionstring = new ConnectionStringSettings("SqlConnectionString", dataSource);
                config.ConnectionStrings.ConnectionStrings.Add(connectionstring);

                config.Save(ConfigurationSaveMode.Modified, true);
                ConfigurationManager.RefreshSection("connectionStrings");
            }
            catch (Exception ex)
            {
                throw new InstallException("A forced exception", ex);
            }
        }


While installing i am getting two error message

<img src="http://i43.tinypic.com/2cr3u5c.jpg" border="0" alt="Image and video hosting by TinyPic">
<img src="http://i43.tinypic.com/2ym9jk1.jpg" border="0" alt="Image and video hosting by TinyPic">

Can anyone please guide me to solve this.
Thanks in advance.
Posted
Comments
[no name] 15-Jul-13 6:51am    
The error message that you get are URLs to tinypic.com that do not go anywhere?
sahabiswarup 15-Jul-13 6:58am    
http://i43.tinypic.com/2cr3u5c.jpg
http://i43.tinypic.com/2ym9jk1.jpg

Now check the links.

1 solution

Check the following Steps:
1.Select the referring DLLs of the application right click> Properties> Set copy to local to True.
2.Check how you have passed parameters in Custom Action Data.
3.Check whether you have added content file too along with primary output file in setup Project.

Thanks,
Purushotham
 
Share this answer
 
Comments
sahabiswarup 18-Jul-13 2:40am    
All you mentioned in your solution is properly done; you might skip my question.
I don't get any error while creating normal setup of my application, but i want to customize it like your way; i put the datasource, Dbname, sqlserver username and password and this value will save in the app.config.
SO i want to write code in the installer class. That i've already mentioned in my question (as per your code). So can you please tell me what to do if i want to configure my datatasource while installing the application.
Purushotham Agaraharam 18-Jul-13 3:06am    
Is it possible to give you more information regarding the error which you encountered to help u better..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900