加密应用程序设置时出错

时间:2012-11-04 03:59:46

标签: c# .net aspnet-regiis.exe

我一直在使用Settings.settings文件来存储应用程序数据。

<applicationSettings>
    <SLA_TestService.Properties.Settings>
      <setting name="AuthenticationName" serializeAs="String">
        <value>IBR</value>
      </setting>
      <setting name="AuthenticationPassowrd" serializeAs="String">
        <value>IBR</value>
      </setting>
    </SLA_TestService.Properties.Settings>
</applicationSettings>

我使用

加密applicationSettings
aspnet_regiis -pe "applicationSettings/SLA_TestService.Properties.Settings" -app     "/SLAMobility"

我使用;

访问设置
string pword = Properties.Settings.Default.AuthenticationPassowrd

然而它会引发以下错误;

ExceptionType=System.Configuration.ConfigurationErrorsException
StackTrace=
  at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult)
  at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject)
  at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
  at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
  at System.Configuration.ConfigurationManager.GetSection(String sectionName)
  at System.Configuration.ClientSettingsStore.ReadSettings(String sectionName, Boolean isUserScoped)
  at System.Configuration.LocalFileSettingsProvider.GetPropertyValues(SettingsContext context, SettingsPropertyCollection properties)
  at System.Configuration.SettingsBase.GetPropertiesFromProvider(SettingsProvider provider)
  at System.Configuration.SettingsBase.GetPropertyValueByName(String propertyName)
  at System.Configuration.SettingsBase.get_Item(String propertyName)
  at System.Configuration.ApplicationSettingsBase.GetPropertyValue(String propertyName)
  at System.Configuration.ApplicationSettingsBase.get_Item(String propertyName)
  at SLA_TestService.Properties.Settings.get_AuthenticationName() in C:\Users\Mananu\documents\visual studio 2010\Projects\SLA_TestService\SLA_TestService\Properties\Settings.Designer.cs:line 31
  at SLA_TestService.Controllers.ValuesController.GetValues() in C:\Users\Mananu\documents\visual studio 2010\Projects\SLA_TestService\SLA_TestService\Controllers\ValuesController.cs:line 15
  at lambda_method(Closure , Object , Object[] )
  at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass13.<GetExecutor>b__c(Object instance, Object[] methodParameters)
  at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)
  at System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func`1 func, CancellationToken cancellationToken)

我做错了什么? 在此先感谢!!

1 个答案:

答案 0 :(得分:0)

我相信你犯了一个错字。

在配置文件中,将“AuthenticationPassowrd”更改为“AuthenticationPassword”。