Click here to Skip to main content
15,894,825 members
Articles / Desktop Programming / Windows Forms

Encrypting the app.config File for Windows Forms Applications

Rate me:
Please Sign up or sign in to vote.
4.08/5 (11 votes)
17 Apr 2007CPOL2 min read 319.7K   5.3K   77  
Encrypting the app.config file for Windows Forms Applications
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
        <section name="Vault" type="System.Configuration.NameValueSectionHandler" />
        <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
            <section name="EncryptConnStringsSection.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
        </sectionGroup>
    </configSections>
    <connectionStrings>
        <add name="EncryptConnStringsSection.My.MySettings.testConn"
            connectionString="Data Source=someserver;Initial Catalog=ProjectX_Dev;Integrated Security=True" />
    </connectionStrings>
    <system.diagnostics>
        <sources>
            <!-- This section defines the logging configuration for My.Application.Log -->
            <source name="DefaultSource" switchName="DefaultSwitch">
                <listeners>
                    <add name="FileLog"/>
                    <!-- Uncomment the below section to write to the Application Event Log -->
                    <!--<add name="EventLog"/>-->
                </listeners>
            </source>
        </sources>
        <switches>
            <add name="DefaultSwitch" value="Information" />
        </switches>
        <sharedListeners>
            <add name="FileLog"
                 type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
                 initializeData="FileLogWriter"/>
            <!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
            <!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/> -->
        </sharedListeners>
    </system.diagnostics>
    <Vault>
        <add key="var1" value="Hello world!" />
    </Vault>
    <applicationSettings>
        <EncryptConnStringsSection.My.MySettings>
            <setting name="aTest" serializeAs="String">
                <value>Hello world!!!!!</value>
            </setting>
        </EncryptConnStringsSection.My.MySettings>
    </applicationSettings>
</configuration>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Netherlands Netherlands
Name : A.C.F. de Ron B ICT (Ton)
Position : Senior System designer
Date of birth : 15-12-1971
Nationality : Dutch
Language : Dutch, English
Experience since : 1996
Blog : http://www.tronsoft.nl
Summary :

After my study Business Administration Informatics at the University for Economic Studies, In gained experience as a Database Designer, Software Developer, Software Engineer, Tester and .NET coach. With Centura Team Developer I built several applications for social care foundations and for the life insurance branch, e.i. Winterthur and Zwisterleven.

Also I worked for Philip Morris Holland where I maintained and developed on the specification system for cigarettes. Also I worked there on .Net projects which aided production logistics. At this moment I work for Unilever Research where I designed and implemented a formulation creation tool and a monitor stock administration application using .Net 2.0 and Visual Studio.Net 2005.

Comments and Discussions