Hi everyone
How can I clear custom project settings? No matter whether I set the value to null
settings[""] = null;
or set the settings object to null
settings = null;
it keeps returning. Does it live forever in the .aprx? Like a zombie 😉
Thank you and regards,
daniel
Solved! Go to Solution.
If you are talking about 'custom project settings' then your findings are correct. The API exposes only two overrides in the Module class that allow to read/write the project settings: OnReadSettingsAsync and OnWriteSettingsAsync. And you are correct since once you create those settings initially and save the project file your settings stick around for good. OnWriteSettingsAsync only allows you to replace an existing setting and doesn't allow you to delete any existing settings from the key/value pair list of project settings. As a workaround I would suggest to add a boolean setting named something like "UseDefaults" and set that to true in order to clear any existing settings. Once you read settings, check for "UseDefaults" and if its value is true just ignore all other existing settings.
If you are talking about 'custom project settings' then your findings are correct. The API exposes only two overrides in the Module class that allow to read/write the project settings: OnReadSettingsAsync and OnWriteSettingsAsync. And you are correct since once you create those settings initially and save the project file your settings stick around for good. OnWriteSettingsAsync only allows you to replace an existing setting and doesn't allow you to delete any existing settings from the key/value pair list of project settings. As a workaround I would suggest to add a boolean setting named something like "UseDefaults" and set that to true in order to clear any existing settings. Once you read settings, check for "UseDefaults" and if its value is true just ignore all other existing settings.
Thanks for the clarification, Wolfgang