Solved

Installer Class To Edit Config File

Posted on 2013-06-20
4
407 Views
Last Modified: 2013-06-21
Hi Experts!

Thanks for reading this.

Using setup and deployment to create an msi and based on the response from the User Interface (RadioButtons):

user interface in setup and deploymentWe'll use the button selected to determine the Region.
In the Installer class in the Commit method it will edit the config file for TimeToSleep depending on the Region selected (RadioButton):
<Security.Permissions.SecurityPermission(Security.Permissions.SecurityAction.Demand)>
Public Overrides Sub Commit(ByVal savedState As IDictionary)

    Try
        MyBase.Commit(savedState)
        If MyBase.Context.Parameters("Region").ToString() = "1" Then
            My.Settings.Item("TimeToSleep") = "1000"          
        ElseIf MyBase.Context.Parameters("Region").ToString() = "2" Then
            My.Settings.Item("TimeToSleep") = "100"        
        ElseIf MyBase.Context.Parameters("Region").ToString() = "3" Then
            My.Settings.Item("TimeToSleep") = "10"        
        End If

    Catch exc As Exception
        MsgBox("Error performing commit tasks - " & exc.ToString(), "AppName Setup")
    End Try

End Sub 'Commit

Open in new window

Can you please help convert the above to C# (tried using VB.NET -> C# converter didn't help). This is what we have so far:
public override void Commit(IDictionary savedState)
{
    base.Commit(savedState);
}

Open in new window


TIA!!
0
Comment
Question by:allanau20
  • 2
  • 2
4 Comments
 
LVL 35

Accepted Solution

by:
Miguel Oz earned 500 total points
ID: 39265066
Translated code:
        public  override void Commit(IDictionary savedState)
        {
            try
            {
                base.Commit(savedState);
                string myRegion = base.Context.Parameters["Region"].ToString();
                if (myRegion == "1")
                    Properties.Settings.Default.TimeToSleep = "1000";
                else if (myRegion == "2")
                    Properties.Settings.Default.TimeToSleep = "100";
                else if (myRegion == "3")
                    Properties.Settings.Default.TimeToSleep = "10";
            }
            catch (Exception exc)
            {
                MessageBox.Show("Error performing commit tasks - " + exc.ToString(), "AppName Setup");
            }
        }

Open in new window

where settings  are mapped as shown here.
0
 
LVL 5

Author Comment

by:allanau20
ID: 39266923
Thanks; that's helpful mas_oz2003.

In the article it doesn't specific what to reference to use 'Properties'.
I'll try to look around ..
0
 
LVL 5

Author Comment

by:allanau20
ID: 39266996
got it; it was a namespace issue. Thanks!
0
 
LVL 35

Expert Comment

by:Miguel Oz
ID: 39267483
No worries. Please accept solution to close question
Cheers,

MS
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

895 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

12 Experts available now in Live!

Get 1:1 Help Now