Solved

Installer Class To Edit Config File

Posted on 2013-06-20
4
406 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This video discusses moving either the default database or any database to a new volume.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

757 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

22 Experts available now in Live!

Get 1:1 Help Now