Reputation: 45
My app.web.config has custom config section NameValueSectionHandler
, but aspnet_regiis cannot find it.
I need to deploy my WPF app to multiple machines with its app.config encrypted. I already tried many walkthrough with aspnet_regiis but nothing works. I tried:
aspnet_regiis -pc LiteContainer -exp
aspnet_regiis -pef connectionSettings D:\Tes -prov LiteProvider
The error is
"The configuration section 'connectionSettings' was not found".
Failed!
But I successfully can read/write data to this section by code.
App/Web.config
<configuration>
<configSections>
<section name="connectionSettings" type="System.Configuration.NameValueSectionHandler"/>
<sectionGroup name="userSettings" .... </sectionGroup>
</configSections>
<connectionSettings>
<server>192.168.1.xxx</server>
<database>myDb</database>
<uid>root</uid>
<pwd>123</pwd>
</connectionSettings>
<configProtectedData>
<providers>
<add name="LiteProvider"
keyContainerName="LiteContainer"
useMachineContainer="true"
description="Uses RsaCryptoServiceProvider to encrypt and decrypt"
type="System.Configuration.RsaProtectedConfigurationProvider/>
</providers>
</configProtectedData>
</configuration>
I haven't seen any walkthrough encrypt NameValueSectionHandler
before, many used applicationSettings
or connectionStrings
. What am I missing here?
Upvotes: 1
Views: 2282
Reputation: 65594
I think your command is wrong, even if the folder D:\Tes contains your web.config:
aspnet_regiis -pef connectionSettings D:\Tes -prov LiteProvider
You've mis-typed connectionSettings instead of the connectionStrings:
%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis -pef "connectionStrings" <full path to directory containing web.config file>
isn't the syntax aspnet_regiis -pef [section name] [web.config path] ? the section name is connectionSettings not connectionStrings
Here is the result when I try it on my PC.
Copy an App.Config with AppSettings (or ConnectionStrings) sections to C:\Temp, and rename it to Web.config.
Run this command: %windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis -pef "appSettings" c:\Temp
After running the aspnet_regiis command the appSettings is encrypted:
Your XML isn't the format expected, eg:
<server>192.168.1.xxx</server>
<database>myDb</database>
<uid>root</uid>
Use the standard appSettings or connectionStrings format:
<appSettings>
<add key="server" value="192.168.1.xxx"/>
<add key="database" value="myDb"/>
<add key="uid" value="root"/>
<add key="pwd" value="123"/>
</appSettings>
Upvotes: 2