Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Windows Service - Project Installer

Posted on 2009-05-11
4
530 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 500 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

840 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