Solved

Windows Service - Project Installer

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

914 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now