Solved

Windows Service - Project Installer

Posted on 2009-05-11
4
540 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
[X]
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
  • 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Convert Silverlight ERP To Angularjs,HTML5 3 62
global Variable - 2 functions in powershell 1 22
asp.net web app 3 27
CSS for Popup in ASP.NET 4 19
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

730 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