Multiple settings per extension - Take care

Topics: Controls
Mar 1, 2008 at 1:55 PM
In some extension like BBCode or SnapShot, thats who need Edit options after updating to last change sets you obtain two settings for this extensions, and when you try to edit one of this you have this exception:
Referencia a objeto no establecida como instancia de un objeto.
Descripción: Excepción no controlada al ejecutar la solicitud Web actual. Revise el seguimiento de la pila para obtener más información acerca del error y dónde se originó en el código.
Detalles de la excepción: System.NullReferenceException: Referencia a objeto no establecida como instancia de un objeto.
Error de código fuente:
Línea 237:    void CreateFormFields()
Línea 238:    {
Línea 239:        foreach (ExtensionParameter par in _settings.Parameters)
Línea 240:        {
Línea 241:            ErrorMsg.InnerHtml = string.Empty;
Archivo de origen: h:\BlogEngine\BlogEngine\BlogEngine.NET\admin\Extension Manager\Settings.ascx.cs    Línea: 239 
that is because in settings.aspx.cs can not load controls and _settings become null, you can see this with a breakpoint in:
    protected void Page_Load(object sender, EventArgs e)
    {
        _extensionName = this.ID;
        _settings = ExtensionManager.GetSettings(_extensionName);
 
        CreateFormFields();
 ...

SOLUTION: delete thats extensions, run application without that extension and made a little change in status of other extension, then you can put again thats extensions and run application again.

Sorry I can not find where BE create two settings for this type of extensions, i think it is a problem when extension are in database (I use SQLProvider) and aply the last change set. Of course is a good idea that we can enable o disable extension from admin page and not to delete class source.

BE team, when you find a better solution please let me know.
Coordinator
Mar 1, 2008 at 9:51 PM
This problem is due to adding new property to the settings object. Unfortunately, settings saved in the DB as blob, so you can't just add new record. There is a good chance we'll be replacing blob with several tables for exactly this reason, but until then you'll need to do what you described to get around it: remove extension that saves property in the database, run application so it will reset to defaults and then add extension back and update settings if needed.
I'll fix this over weekend so you won't need this workaround.
Coordinator
Mar 2, 2008 at 4:36 AM
Latest build (9891) should fix this problem.
Mar 2, 2008 at 10:37 AM
Thanks Ruslan.
Skiping wrong settings.Name is a good (better) solution, but users who do not delete their extensions still with two settings. We need a cleaner.
Coordinator
Mar 2, 2008 at 4:29 PM

jtentor wrote:
Skiping wrong settings.Name is a good (better) solution, but users who do not delete their extensions still with two settings. We need a cleaner.

They should only have one setting. Skipping is a "safety net", there is a cleaner too - on load from DB it assign setting without name extension's name as a default. You might end up with duplicate only if you already have one - you'll see two settings with same name on admin setting page. Then you'll need to remove extension to clean it up.
Mar 2, 2008 at 6:44 PM
Ok, thanks again.