我正在尝试对我正在开发的 C# 应用程序的 app.config 文件中的敏感连接字符串信息进行加密。我正在以管理员身份运行的 VS 命令提示符中使用以下命令:
aspnet_regiis.exe -pef "Credentials" "C:\Users\.....\MyProjectFolderDir"
这是我的 app.config 文件的结构:
<?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>
但是,我不断收到以下错误:
正在加密配置部分... 未找到配置部分“凭据”。失败的!
我怎样才能得到这个来加密我的部分?