Solved

Installer Class To Edit Config File

Posted on 2013-06-20
4
412 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
[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
  • 2
  • 2
4 Comments
 
LVL 36

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 36

Expert Comment

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

MS
0

Featured Post

Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

Question has a verified solution.

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

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 …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

688 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