InstaSharp
InstaSharp copied to clipboard
Error at configuration system
Show me the following exception error: The current configuration system does not support user-scoped settings
please help me
Try going to Properties -> Settings for the solution and change any items that have User for scope to Application.
Thanks for your replying,
I solved it by using appSettings in app.config file like this:
<appSettings>
<add key="deviceId" value=""/>
<add key="guid" value=""/>
</appSettings>
Read/write from/on these properties using the following c# class:
using System.Configuration;
using System.Web.Configuration;
namespace InstaSharp
{
public class AppSettingsManager
{
public static string ReadSetting(string key)
{
try
{
var appSettings = ConfigurationManager.AppSettings;
string result = appSettings[key] ?? "Not Found";
return result;
}
catch (ConfigurationErrorsException)
{
return "";
}
}
public static void AddUpdateAppSettings(string key, string value)
{
try
{
var configFile = WebConfigurationManager.OpenWebConfiguration("~");
var settings = configFile.AppSettings.Settings;
if (settings[key] == null)
{
settings.Add(key, value);
}
else
{
settings[key].Value = value;
}
configFile.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection(configFile.AppSettings.SectionInformation.Name);
}
catch (ConfigurationErrorsException ex)
{
throw ex;
}
}
}
}
Making Updates in InstagramUploader.cs file after line no. 93 as:
string guid;
string deviceId;
//save our device/guid so we look like we're always uploading from the same phone
string currentDeviceIDValueToCheck = AppSettingsManager.ReadSetting("deviceId");
if (!string.IsNullOrEmpty(currentDeviceIDValueToCheck))
{
guid = AppSettingsManager.ReadSetting("guid");
deviceId = currentDeviceIDValueToCheck;
}
else
{
guid = GenerateGuid();
deviceId = $"android-{guid}";
// 4 web app
AppSettingsManager.AddUpdateAppSettings("deviceId", deviceId);
AppSettingsManager.AddUpdateAppSettings("guid", guid);
// 4 desktop app
//Settings.Default.deviceId = deviceId;
//Settings.Default.guid = guid;
//Settings.Default.Save();
}
This helped me to posting to my Instagram page by your website
Thanks
Hi @msaah85
If you submit a pull request I'd be happy to merge.
I set some updates on this API:
- Using AppSettings for web developers.
- Uploading Base64 image string.
Of course I`m ready to push all updates that i have to you @Codeusa .