none
The 'useMachineProtection' attribute is not declared RRS feed

  • Question

  • Hello,

    I want to encrypt a database password stored in my .NET 3.5 VS 2008 C# application's configuration file.  I added the following configProtectedData section to the App.config file, which seems to work okay when I use the following code to encrypt the connectionStrings section.

    However in the Visual Studio IDE I am getting the warning "The 'useMachineProtection' attribute is not declared"
    How can I make that warning go away?
    Do I need to add something to the configSections?

    Thanks,
    Greg

      <configProtectedData>
        <providers>
          <add useMachineProtection="true" name="DPAPIProtection"
               type="System.Configuration.DpapiProtectedConfigurationProvider,
                     System.Configuration, Version=2.0.0.0, Culture=neutral,
                     PublicKeyToken=b03f5f7f11d50a3a" />
        </providers>
      </configProtectedData>

    Configuration config = ConfigurationManager.OpenExeConfiguration(...);
    if (!config.ConnectionStrings.SectionInformation.IsProtected)
    {
       config.ConnectionStrings.SectionInformation.ProtectSection("DPAPIProtection");
    }
    config.Save();
    Thursday, August 14, 2008 2:20 AM

All replies