Question

I have been using the Settings.settings file for storing application data.

<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>

I encrypt the applicationSettings using

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

And I access the settings using;

string pword = Properties.Settings.Default.AuthenticationPassowrd

However it throws the following error;

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)

What am I doing wrong? Thanks in Advance!!

No correct solution

OTHER TIPS

You have made a typo, I believe.

In your configuration file, change "AuthenticationPassowrd" to "AuthenticationPassword".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top