Hello,
we are using the new XAF data dashboards module and noticed that it is not possible to load data via the ObjectDataSource when the referenced type is in a signed assembly and the assembly version changed.
To reproduce this, start the attached demo and invoke the "Show Dashboard Designer" action: the "Object Data Source 1" shows the properties of the Invoice type and the chart shows some data (Screenshot 1.png).
Now change the version of the DashboardsModule1.Module project (Screenshot 2.png): the "Object Data Source 1" shows no properties and the chart does not show any data (Screenshot 3.png).
Olaf
This is expected behavior. The Dashboard control saves information about the data source class with the full assembly version. If the version has been changed, the old class version cannot be created and no data is loaded. The problem only appears if an assembly is signed with a PublicKeyToken. We suggest the following ways of avoiding this problem:
Update: The DashboardLoaded event is not a good solution if different data sources are used in a certain project. In this case, it is better to use the solutions described in the A note on the serialization of custom libraries. help topic to specify which type should be used instead of the old one.
When I handle the DashboardLoaded event: do you have any suggestions how to access then the "not loaded type" - the DataSource property of the ObjectDataSource object is null/nothing…?
…in a real world app I don't have only one dashboard with only one data type, so please don't suggest to use
ObjectDataSource.DataSource = GetType(Invoive)
It appears that I provided you with an incomplete answer earlier. I apologize for that.
You are right, the DashboardLoaded event is not a good solution if different data sources are used in a certain project. In this case, it is better to use the solutions described in the A note on the serialization of custom libraries. help topic to specify which type should be used instead of the old one.
Hello Olaf,
We have found probably a more convenient temporary solution than the one from XML Serialization or based on the DashboardLoaded event, because it does not require you to create a list of assemblies or types to resolve manually. This solution updates all DashboardData records automatically during a database update when a new version is delivered to clients:
using System; using System.Collections.Generic; using System.Linq; using System.Xml.Linq; // Do not forget to reference the System.Xml.Linq.dll too. using DevExpress.ExpressApp; using DevExpress.ExpressApp.Dashboards; using DevExpress.Persistent.Base; using DevExpress.Persistent.BaseImpl; namespace YourSolutionName.Module.DatabaseUpdate { public class Updater : DevExpress.ExpressApp.Updating.ModuleUpdater { public Updater(IObjectSpace os, Version currentDBVersion) : base(os, currentDBVersion) { } public override void UpdateDatabaseAfterUpdateSchema() { base.UpdateDatabaseAfterUpdateSchema(); UpdateDashboardDataSource(); } private void UpdateDashboardDataSource() { IList<DashboardData> allDashboards = ObjectSpace.GetObjects<DashboardData>(); foreach(DashboardData dashboardData in allDashboards) { XDocument document = dashboardData.LoadDocument(); var allDataSources = document.Descendants("DataSource"); foreach(XElement element in allDataSources) { XAttribute typeAttribute = element.Attributes("Type").FirstOrDefault(); string typeName = typeAttribute.Value.Substring(0, typeAttribute.Value.IndexOf(',')); Type resultType = ReflectionHelper.FindType(typeName); typeAttribute.Value = resultType.AssemblyQualifiedName; } dashboardData.SaveDocument(document); } ObjectSpace.CommitChanges(); } } }
What do you think about it?
If we find a better solution, we will let you know.
Hello Dennis,
I ended up with a solution similar to this - load a XmlDocument and process the nodes.
Olaf
Thanks for your update, Olaf.
I must note that this is not final 'solution' and it has drawbacks, but for now this is the only automatic way we can offer. We are currently discussing better options with our Dashboards team. We will update your ticket once we have new information. If there are no reliable solutions at our end, we will consider describing this in the documentation for the dashboard and related modules.
Olaf, I just wanted to inform you that we reactivated your ticket, which means that we are looking for a final solution. Please do not be confused by this. We also want to keep it public so that other Dashboard users are aware of this situation and current solutions.
We will update your ticket once we have new information.