Encryprting connection string: "This operation does not apply at runtime"
<p>I have a console application and it has app.config. When I run this code:</p>

<pre><code> class Program
    {
        static void Main()
        {

            ConnectionStringsSection connSection = ConfigurationManager.GetSection("connectionStrings") as 
                                                    ConnectionStringsSection;
            if (connSection != null)
            {
                if (!connSection.SectionInformation.IsProtected)
                    connSection.SectionInformation.ProtectSection("RsaProtectedConfigurationProvider");

                else
                    connSection.SectionInformation.UnprotectSection();
            }

            Console.Read();
        }
    }
</code></pre>

<p>I get error: "This operation does not apply at runtime". I also tried giving permissions to my app.config but no luck.</p>

<p>What can the issue?</p>
