Why editing dynamic controls fails...

by dan 23. November 2009 12:55

Today my AxConsultant colleague Sascha Poth called me to complain about a nasty AxCMS.net 9.0 behavoir: It is fairly impossible to edit an AxCMS.net ElementTemplate. Minutes later, my fellow colleague Tim Kühl called my to complain about exactly the same thing...

I did a little research for myself to look if they were right:

As soon as I pressed the edit key in the frontend:

 


the following error message appeared:

 

ok... what could it be?

Looking at the exception.txt the following hint was given:

 System.InvalidCastException: Das Objekt des Typs "System.DBNull" kann nicht in Typ "System.String" umgewandelt werden.
   bei Axinom.AECMS.WebControls.AxStructureElement.LoadProperties(DataRow row)
   bei Axinom.AECMS.WebControls.AxStructureElement.LoadDB()
   bei Axinom.AECMS.WebControls.AxControlUtility.LoadAxControl(IClassifiable element)
   bei AxCMS.AxCMSweb.Concept.b(IClassifiable A_0)

So I set up a little unit test to check if everything is alright. The outcome:

Following code is totally ok:

            AxStructureElement element = new AxStructureElement();
            element.AxID = 13;
            element.LoadDB();

This code reflects the first two rows in the error messages by manually loading the AxStructureElement in carge.

Adding these three lines reproduces the error shown above:

            AxStructureElement element = new AxStructureElement();
            element.AxID = 13;
            element.LoadDB();

            IAxControl control = (IAxControl)AxControlUtility.CreateElement((ElementTypes)element.Type);
            control.AxID = (int)((IClassifiable)element).ID;
            control.LoadDB();

Where is the trick in it? The AxControlUtility.LoadAxControl(element) function uses exactly the three lines added above. When you did deep enough into the AxStructureElement class you will see that the IClassifiable interface is implemented at least incomplete: It does not return the elements AxID as it is supposed to do but it return the elements TemplateID

Edit:

Axinom quickly responded and provides their partners with a patched .dll file. Please contact your local partner support manager if you need to get it!

Best,
Dan


Comments are closed

Dan Wucherpfennig - AxCMS.net evangelist

Dan Wucherpfennig is an IT consultant employed at EDV-Partner (http://www.edvpartner.de), a Hamburg based system integration and consulting company. 

Having many years of experience in developing projects with AxCMS.net, Dan has been awarded as an AxConsultant during the AxDays 2008.

Calendar

<<  July 2010  >>
MoTuWeThFrSaSu
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

View posts in large calendar