none
Format of the initialization string does not confirm to specification starting at index 0 RRS feed

  • Question

  • Hi,

    I am using the code from:

    http://weblogs.asp.net/jongalloway/encrypting-passwords-in-a-net-app-config-file

    to encrypt and decrypt connectionstring in my application configuration file but getting:

    Format of the initialization string does not confirm to specification starting at index 0

    here is my code:

    string connection_string;
    
    ExeConfigurationFileMap oConfigFile = new ExeConfigurationFileMap();
    oConfigFile.ExeConfigFilename = "C:\\Users\\CakeBoutique\\AppData\\Roaming\\Softnames\\" + folder_name + "\\" + file_name + ".config";
    Configuration oConfiguration = ConfigurationManager.OpenMappedExeConfiguration(oConfigFile, ConfigurationUserLevel.None);
    connection_string = oConfiguration.ConnectionStrings.ConnectionStrings[connection_name].ConnectionString;
    
    return security_encryptor.ToInsecureString(security_encryptor.DecryptString(connection_string));
    

    Friday, October 2, 2015 11:59 PM

All replies

  • Hi Jassim Rahma,

    [Format of the initialization string does not confirm to specification starting at index 0]

    This error means the format of  connection string which you use is not right. You have to decrypt your connection string before you use.

    Best Regards,
    Li Wang

    Monday, October 5, 2015 8:18 AM
    Moderator
  • but that's what I did here:

    return security_encryptor.ToInsecureString(security_encryptor.DecryptString(connection_string));

    Monday, October 5, 2015 9:01 AM
  • Hi Jassim,

    Did you use below way to encrypt connection string?

    string encnnString = EncryptString(ToSecureString(connectionstring));

    You could set a breakpoint in your code and view the the result of security_encryptor.ToInsecureString method.

    Best Regards,
    Li Wang


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, October 19, 2015 9:30 AM
    Moderator