Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Settings not written #3

Closed
aliirz opened this issue Sep 12, 2013 · 11 comments
Closed

Settings not written #3

aliirz opened this issue Sep 12, 2013 · 11 comments

Comments

@aliirz
Copy link

aliirz commented Sep 12, 2013

Hi Again

I am using the nuget in a class library i call to save settings. However i can see the file being created but it appears to be empty and when I try to read it, i get empty values. What am I doing wrong?

Please help.

@JakeGinnivan
Copy link
Owner

Not sure.

I am thinking about changing this to a library rather than just putting the code into your project. This will make it easier to hide internals and make it easier to get started.

Can you paste some code so I can see what you are doing?

@aliirz
Copy link
Author

aliirz commented Sep 13, 2013

Hi @JakeGinnivan thanks for replying. These are the following two methods I am using in order o save and retrieve the settings:

 public ClientSettings GetClientSettings()
 {
            SettingsProvider provider = new SettingsProvider();
            return provider.GetSettings<ClientSettings>(false);   //I cant seem to call the Load Method for some reason. I think its no longer supported.
 }
public bool SaveClientSettings(ClientSettings settings)
{
            try
            {
                provider.SaveSettings<ClientSettings>(settings);
            }
            catch (Exception ex)
            {
                return false;
            }
            return true;
}

And this is what my ClientSettings class looks like:

 [Serializable]
    public class ClientSettings
    {
        public int orgID { get; set; }
        public string username { get; set; }
    }

I will really appreciate if you can help with this. Thanks

@aliirz
Copy link
Author

aliirz commented Sep 13, 2013

This is how client settings look like when created, I always setup the parameters but notice how its 0 kb. I have opened it and tried reading it as well via the above code but i can never retrieve the settings...

clientsettings

@JakeGinnivan
Copy link
Owner

The class doesn't have to be marked as serializable.

Interesting. That looks like a bug (I have only reused the settings provider rather than newing it up every time). I think it is related to that. Try making it a static property and ill look into it over the weekend

@aliirz
Copy link
Author

aliirz commented Sep 13, 2013

Thanks @JakeGinnivan I will check by creating it as a static property.

@aliirz
Copy link
Author

aliirz commented Sep 14, 2013

Still not working :( This is how i have implemented the static instance of the provider now:

public static SettingsProvider _settingsProvider;

static SettingsService()
{
            _settingsProvider = new SettingsProvider();
}

public ClientSettings GetClientSettings()
{
           return _settingsProvider.GetSettings<ClientSettings>();
}

public bool SaveClientSettings(ClientSettings settings)
{
    try
    {
           _settingsProvider.SaveSettings<ClientSettings>(settings);
    }
    catch (Exception ex)
    {
           return false;
    }
          return true;
 }

@JakeGinnivan
Copy link
Owner

Try uninstalling, deleting the classes which are put into your project, then reinstalling. I fixed a bug a few weeks ago which caused things not to write properly

I am working on v2 which will be a class library, but will be a few more days

@aliirz
Copy link
Author

aliirz commented Sep 15, 2013

Ok I will add directly from the github repo rather than using the nuget package.

@aliirz
Copy link
Author

aliirz commented Sep 15, 2013

Sadly I got the same result :( I can see the created file but its empty, no settings inside it.

@aliirz
Copy link
Author

aliirz commented Sep 18, 2013

Hey @JakeGinnivan any updates on this?

Regards

@JakeGinnivan
Copy link
Owner

@aliirz I know it has been ages, I have just finished overhauling the internals and converting this to a class library in prep for v2. Once its released if you still need this let me know how you go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants