[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Installer Class To Edit Config File

Posted on 2013-06-20
4
Medium Priority
?
414 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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
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…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

650 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