با سلام و خسته نباشید
دوستان من app.config برنامه خودم را با استفاده از تابع زیر encrypt کردم و روی کامپیوتر خودم به درستی عمل می کند و لی زمانی که برنامه روی سیستم دیگری کپی می شود پیام خطا می دهد که نمی توان dycrypt انجام دهد لطفا راهنمایی کنید
static void ToggleConfigEncryption(string exeConfigName)
{
// Takes the executable file name without the
// .config extension.
try
{
// Open the configuration file and retrieve
// the connectionStrings section.
Configuration config = ConfigurationManager.OpenExeConfiguration(exeConfi gName);
ConnectionStringsSection section =
config.GetSection("connectionStrings")
as ConnectionStringsSection;
if (section.SectionInformation.IsProtected)
{
// Remove encryption.
// section.SectionInformation.UnprotectSection();
}
else
{
// Encrypt the section.
section.SectionInformation.ProtectSection(
"DataProtectionConfigurationProvider");
}
// Save the current configuration.
AppSettingsSection st2 = config.GetSection("appSettings") as AppSettingsSection;
if (!st2.SectionInformation.IsProtected)
st2.SectionInformation.ProtectSection("DataProtect ionConfigurationProvider");
// config.Sections.Add(
config.Save(ConfigurationSaveMode.Full);
// Console.WriteLine("Protected={0}",
// section.SectionInformation.IsProtected);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
تو کامپیوتر دیگری که اجرا می کنم پیام زیر نشون داده میشه
untitled.JPG