?
Solved

Windows Service - Project Installer

Posted on 2009-05-11
4
Medium Priority
?
557 Views
Last Modified: 2012-08-14
Hello Experts,

I am developing a Windows Service application in .Net.

While installing the service should take some config values from users and update the user settings in app.config file.

I have a Windows FORM in my project and i could call the windows FORM in my installer class.

public override void Install(System.Collections.IDictionary stateSaver)
        {
            base.Install(stateSaver);
         
            frmUserSettings f = new frmUserSettings()
                     
            f.ShowDialog();
           
        }


-------------------------------

the above code works and the FORM shows up during installation.

now i need to get the values from the FORM and update the user settings information in the app.config file.

any help?

Thanks
0
Comment
Question by:mani_sai
  • 3
4 Comments
 
LVL 8

Author Comment

by:mani_sai
ID: 24358308
I removed windows FORM and tried using  Deployment project - User Interface Text boxes.
This is the code i am using right now in my installer code:
--------------------------
public override void Install(System.Collections.IDictionary stateSaver)
{
base.Install(stateSaver);
string str = Context.Parameters["SENDEREMAILADDRESS"].ToString();
Settings1 UserSettings = new Settings1();
UserSettings.EmailSender = str;
UserSettings.Save();
}
------------------------------
when i run, i am getting object reference not set to an instance
any idea what i am missing?
 
 
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 1500 total points
ID: 24358443
Make some public properties on your form so that you can access its data after the user has made the appropriate entries. Then you can add the data to your app.config file.
///////////////////////////////
//  Form code
///////////////////////////////
public class frmUserSettings : System.Windows.Forms.Form
{
    public string UserName { get; set; }
 
    protected void Form_Closing(object sender, EventArgs e)
    {
        this.UserName = this.textBox1.Text;
    }
}
 
///////////////////////////////
//  Service code
///////////////////////////////
public override void Install(System.Collections.IDictionary stateSaver)
{
    base.Install(stateSaver);
 
    frmUserSettings f = new frmUserSettings();
    
    f.ShowDialog();
    // Access via: f.UserName;
}

Open in new window

0
 
LVL 8

Author Comment

by:mani_sai
ID: 24358729
thanks for your reply.
I removed Windows Forms. i am using Deployment project - User Interface Text box  
Now when i run my intall process, it is asking for  user parameter and i am using this code in my installer class:
 ----------------------------------------
public override void Install(System.Collections.IDictionary stateSaver)
{
base.Install(stateSaver);
string str = Context.Parameters["SENDEREMAILADDRESS"].ToString();
Settings1 UserSettings = new Settings1();
UserSettings.EmailSender = str;
UserSettings.Save();
}
------------------------------
 i am getting error, object reference set to an instance of the object
 
any idea?
0
 
LVL 8

Author Closing Comment

by:mani_sai
ID: 31580275
thanks
0

Featured Post

Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Screencast - Getting to Know the Pipeline
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question