Solved

Windows Service - Project Installer

Posted on 2009-05-11
4
495 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
Comment Utility
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 74

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
thanks
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

772 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

10 Experts available now in Live!

Get 1:1 Help Now