我想加密我的app.config文件中的C#應用程序,我正在開發敏感的連接字符串信息。我使用下面的命令從VS命令PROMT以管理員身份運行:C# - 找不到配置部分錯誤使用aspnet_regiis.exe
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>
不過,我不斷收到以下錯誤:
Encrypting configuration section... The configuration section 'Credentials' was not found. Failed!
我怎樣才能得到這個加密我科?
您是否嘗試過使用 「配置/證書」?您可能需要深入研究。 – Ju66ernaut
你的app.config文件不應該以開始而不是?因此,該文件的開始應該是<?xml version =「1.0」encoding =「utf-8」?> –
Mangist
從技術上說是的,但是我在模式方面遇到問題, ''配置的效果被聲明兩次''所以我只是將它重命名爲配置。 –