I am trying to Encrypt sensitive connection string information inside my app.config file for a C# applicaiton that I am developing. I am using the following command from the VS command promt running as administrator:
aspnet_regiis.exe -pef "Credentials" "C:\Users\.....\MyProjectFolderDir"
This is the structure of my app.config file:
<?xml version="1.0" encoding="utf-8" ?>
<config>
<configSections>
<section name="ApplicationSettings" type="sometype"/>
<section name="WebSettings" type="sometype"/>
<section name="Credentials" type="sometype"/>
<section name="SQLServerSettings" type="sometype"/>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<ApplicationSettings Mode="mymode"
FileSearchMode="myfilemode"
SubtractHoursDebugging="0"/>
<WebSettings WebApiServers=""
CredentialMethod="mymethod"/>
<Credentials
Domain="mydomain"
UserName="myusername"
Password="mypassword"/>
<SQLServerSettings
ConnectionString="Server=***********"/>
</config>
However, I keep getting the following error:
Encrypting configuration section... The configuration section 'Credentials' was not found. Failed!
How can I get this to encrypt my section?