Xafari.Editors bug

StatusIDPriorityType
Closed25272BlockerBug
ProfileReply
HakanClient

Hello,

When the Editors and Editors.Web modules are used in a web application, and if a CriteriaPropertyEditor (Xafari or XAF) is in a detailview, the following unhandled exception occurs (popup criteria editor or not):

[NullReferenceException: Object reference not set to an instance of an object.] Xafari.Editors.Model.ModelListViewXafariEditorsLogic.Get_DataAccessMode(IModelListView listViewModel) +20
ModelListView.GetStaticDataAccessModeCalculator(ModelNode node) +53

Version: 15.2.508.692 (Latest)

Attached files:

Replies

UserDescriptionPosted On
Sasha (Xafari Support)Agent

Hello Hakan,
Thank you for contacting us.

We are going to investigate it. Give us some time.

Best regards,
Sasha.

Sasha (Xafari Support)Agent

Hello Hakan,

We apologize for the delayed response.

Please, can you check availability Xafari and Xafari.Web modules in your project?
And inform us what Xafari version do you use?

Thanks, Sasha.

Hakan

Hello Sasha,

Yes, Xafari and Xafari.Web modules are included in my project. They are both referenced and loaded as modules.
And the version is 15.2.508.692 (Latest)

Sasha (Xafari Support)Agent

Hi,

We have replicated this behavior, but it specific situation.
Could you please provide us info about your situation?
A small demo project, reproducing the problem or detailed steps to reproduce the problem (We are especially interested in the type of properties StringTypeMemberName: [CriteriaOptions("StringTypeMemberName")] ).

Best regards,
Sasha.

Hakan

Hello Sasha,

You can find my class implementation below. The error is not only for this class, but for all Criteria Editors in the project.
Also, please help as soon as possible, because 2-3 days later, we have to release a scheduled update for our customers.
Thank you.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DevExpress.ExpressApp.DC;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl;
using DevExpress.Xpo;
using logocrm.net.Module.Globals;
using DevExpress.ExpressApp;
using logocrm.net.Module.BusinessObjects.PrimitiveObjects;
using logocrm.net.Module.BusinessObjects.SupportingTables;
using logocrm.net.Module.NonPersistentObjects;
using DevExpress.ExpressApp.Model;
using DevExpress.ExpressApp.Utils;
using System.ComponentModel;
using DevExpress.ExpressApp.Editors;
namespace logocrm.net.Module.BusinessObjects.Codes
{
[DefaultClassOptions]
[DevExpress.Persistent.Base.CreatableItemAttribute(false)]
[DevExpress.ExpressApp.DC.XafDisplayNameAttribute("Opportunity stage criterion")]
[DevExpress.ExpressApp.DC.XafDefaultPropertyAttribute("StageDescription")]
[DevExpress.Persistent.Base.ImageNameAttribute("cnCriteria")]
public partial class CT_Opportunity_Stages_Criteria : cbnBaseObject
{
private System.DateTime __LastModifiedDateTime;
private ST_User __LastModifiedBy;
private System.DateTime __CreatedDateTime;
private ST_User __CreatedBy;
private Int32 _objectTypeInt;
private string _description;
public CT_Opportunity_Stages_Criteria(DevExpress.Xpo.Session session)
: base(session)
{
}

public override void AfterConstruction()
{
base.AfterConstruction();
ObjectTypeInt = 0;
ObjectType = typeof(MT_Opportunity);
}

protected override void OnSaving()
{
base.OnSaving();
}

protected override void OnChanged(string propertyName, object oldValue, object newValue)
{
base.OnChanged(propertyName, oldValue, newValue);
if ((!IsLoading) && (!IsSaving))
{
if (propertyName == "ObjectTypeInt")
{
switch (ObjectTypeInt)
{
case 0: ObjectType = typeof(MT_Opportunity); break;
case 1: ObjectType = typeof(MT_Activity); break;
case 2: ObjectType = typeof(MT_Event); break;
case 3: ObjectType = typeof(MT_Document); break;
case 4: ObjectType = typeof(MT_Proposals); break;
}
}
}
}

[DevExpress.ExpressApp.DC.XafDisplayNameAttribute("Description")]
[DevExpress.Persistent.Base.VisibleInListViewAttribute(true)]
[Size(100)]
public string Description
{
get
{
return _description;
}
set
{
SetPropertyValue("Description", ref _description, value);
}
}

[DevExpress.Persistent.Base.ImmediatePostDataAttribute]
[DevExpress.ExpressApp.DC.XafDisplayNameAttribute("Module")]
public Int32 ObjectTypeInt
{
get
{
return _objectTypeInt;
}
set
{
SetPropertyValue("ObjectTypeInt", ref _objectTypeInt, value);
}
}

[ModelDefault("AllowNew", "false"), ModelDefault("AllowEdit", "false"), ModelDefault("AllowDelete", "false")]
[DevExpress.Persistent.Base.VisibleInListViewAttribute(false)]
[DevExpress.Persistent.Base.VisibleInDetailViewAttribute(false)]
[DevExpress.ExpressApp.DC.XafDisplayNameAttribute("Module name")]
[ValueConverter(typeof(TypeToStringConverter)), ImmediatePostData]
[TypeConverter(typeof(LocalizedClassInfoTypeConverter))]
public Type ObjectType
{
get { return GetPropertyValue("ObjectType"); }
set
{
SetPropertyValue("ObjectType", value);
Criterion = String.Empty;
}
}

[DevExpress.ExpressApp.DC.XafDisplayNameAttribute("Criterion")]
[CriteriaOptions("ObjectType"), Size(SizeAttribute.Unlimited)]
[EditorAlias(EditorAliases.PopupCriteriaPropertyEditor)]
[DevExpress.Persistent.Base.VisibleInListViewAttribute(true)]
public string Criterion
{
get { return GetPropertyValue("Criterion"); }
set { SetPropertyValue("Criterion", value); }
}

[DevExpress.ExpressApp.DC.XafDisplayNameAttribute("Text")]
[DevExpress.Persistent.Base.VisibleInListViewAttribute(true)]
[Size(SizeAttribute.Unlimited)]
public string CriterionText
{
get { return GetPropertyValue("CriterionText"); }
set { SetPropertyValue("CriterionText", value); }
}

[NonCloneable]
[ModelDefault("AllowNew", "false"), ModelDefault("AllowEdit", "false"), ModelDefault("AllowDelete", "false")]
[DevExpress.ExpressApp.DC.XafDisplayNameAttribute("Created by")]
[DevExpress.Persistent.Base.VisibleInListViewAttribute(false)]
[DevExpress.Persistent.Base.VisibleInDetailViewAttribute(false)]
public ST_User _CreatedBy
{
get
{
return __CreatedBy;
}
set
{
SetPropertyValue("_CreatedBy", ref __CreatedBy, value);
}
}

[NonCloneable]
[ModelDefault("AllowNew", "false"), ModelDefault("AllowEdit", "false"), ModelDefault("AllowDelete", "false")]
[DevExpress.ExpressApp.DC.XafDisplayNameAttribute("Created date")]
[DevExpress.Persistent.Base.VisibleInListViewAttribute(false)]
[DevExpress.Persistent.Base.VisibleInDetailViewAttribute(false)]
public System.DateTime _CreatedDateTime
{
get
{
return __CreatedDateTime;
}
set
{
SetPropertyValue("_CreatedDateTime", ref __CreatedDateTime, value);
}
}

[NonCloneable]
[ModelDefault("AllowNew", "false"), ModelDefault("AllowEdit", "false"), ModelDefault("AllowDelete", "false")]
[DevExpress.ExpressApp.DC.XafDisplayNameAttribute("Last modified by")]
[DevExpress.Persistent.Base.VisibleInListViewAttribute(false)]
[DevExpress.Persistent.Base.VisibleInDetailViewAttribute(false)]
public ST_User _LastModifiedBy
{
get
{
return __LastModifiedBy;
}
set
{
SetPropertyValue("_LastModifiedBy", ref __LastModifiedBy, value);
}
}

[NonCloneable]
[ModelDefault("AllowNew", "false"), ModelDefault("AllowEdit", "false"), ModelDefault("AllowDelete", "false")]
[DevExpress.ExpressApp.DC.XafDisplayNameAttribute("Last modified date")]
[DevExpress.Persistent.Base.VisibleInListViewAttribute(false)]
[DevExpress.Persistent.Base.VisibleInDetailViewAttribute(false)]
public System.DateTime _LastModifiedDateTime
{
get
{
return __LastModifiedDateTime;
}
set
{
SetPropertyValue("_LastModifiedDateTime", ref __LastModifiedDateTime, value);
}
}

[DevExpress.Xpo.AssociationAttribute("RL_Opportunity_Stage_Criteria", UseAssociationNameAsIntermediateTableName = true)]
[DevExpress.ExpressApp.DC.XafDisplayNameAttribute("Opportunity stages")]
public XPCollection OpportunityStageOid
{
get
{
return GetCollection("OpportunityStageOid");
}
}
}
}

Sasha (Xafari Support)Agent

Hello Hakan,

Thanks for the clarification.
We have reproduced your issue for CriteriaPropertyEditor (Xafari or XAF) really and we are going to fix the issue.

To fix this issue you can:

- At first we reccomend you to use attribute [TypeConverter(typeof(FilteredLocalizedClassInfoTypeConverter<BaseObject>))] in place of [TypeConverter(typeof(LocalizedClassInfoTypeConverter))], where you can set other base type for filter instead BaseObject ():

[ModelDefault("AllowNew", "false"), ModelDefault("AllowEdit", "false"), ModelDefault("AllowDelete", "false")] [DevExpress.Persistent.Base.VisibleInListViewAttribute(false)] [DevExpress.Persistent.Base.VisibleInDetailViewAttribute(false)] [DevExpress.ExpressApp.DC.XafDisplayNameAttribute("Module name")] [ValueConverter(typeof(TypeToStringConverter)), ImmediatePostData]
[TypeConverter(typeof(LocalizedClassInfoTypeConverter))]
[TypeConverter(typeof(FilteredLocalizedClassInfoTypeConverter<BaseObject>))]
public Type ObjectType
{
get { return GetPropertyValue("ObjectType"); }
set
{
SetPropertyValue("ObjectType", value);
Criterion = String.Empty;
}
}

- Next step you have to create a new interface (as example IModelListViewXafariEditorsFix) and inherit the interface from the interface IModelListViewXafariEditors:

public interface IModelListViewXafariEditorsFix : IModelListViewXafariEditors
{
[Category("Behavior"), RefreshProperties(RefreshProperties.All)]
new CollectionSourceDataAccessMode DataAccessMode { get; set; }
}
[DomainLogic(typeof(IModelListViewXafariEditorsFix))]
public static class ModelListViewXafariEditorsLogic
{
public static CollectionSourceDataAccessMode Get_DataAccessMode(IModelListView listViewModel)
{
if (listViewModel.Application == null) return CollectionSourceDataAccessMode.Client;
CollectionSourceDataAccessMode dataAccessMode = listViewModel.Application.Options.DataAccessMode;
string str = (listViewModel.EditorType == null) ? "" : listViewModel.EditorType.FullName;
if (((str == "") || (dataAccessMode == CollectionSourceDataAccessMode.Client)) || !str.Contains("Xafari"))
{
return dataAccessMode;
}
string[] source = new string[] { "Xafari.Editors.Win.XafariTreeListEditor", "Xafari.Editors.Win.WinHierarchyNodeListEditor", "Xafari.Editors.Win.WinExplorerListEditor", "Xafari.Editors.Web.ASPxCardListEditor", "Xafari.Editors.Web.ASPxHierarchyNodeListEditor", "Xafari.Editors.Web.ASPxXafariTreeListEditor", "Xafari.Editors.Web.ASPxExplorerListEditor" };
string[] strArray2 = new string[] { "Xafari.Editors.Win.XafariTreeListEditor", "Xafari.Editors.Win.WinHierarchyNodeListEditor", "Xafari.Editors.Web.ASPxHierarchyNodeListEditor", "Xafari.Editors.Web.ASPxXafariTreeListEditor" };
if (((dataAccessMode != CollectionSourceDataAccessMode.DataView) || !source.Contains(str)) && ((dataAccessMode != CollectionSourceDataAccessMode.Server) || !strArray2.Contains(str)))
{
return dataAccessMode;
}
return CollectionSourceDataAccessMode.Client;
}
}

And you have to override the ExtendModelInterfaces() in Module.cs:

public override void ExtendModelInterfaces(ModelInterfaceExtenders extenders)
{
base.ExtendModelInterfaces(extenders);
extenders.Add<IModelListView, IModelListViewXafariEditorsFix>();
}

We hope you find this information helpful.
Let us know if you need further assistance.
Regards,
Sasha.

Sasha (Xafari Support)Agent

Hello Hakan,

This issue resolved in last Xafari v15.2.708.747 partly.
The remaining errors will solve DevExpress: refer to the ASPxCriteriaPropertyEditor throws CannotResolveClassInfoException if an abstract DC interface is selected as the data type

Feel free to contact us if you have any questions.
Best regards,
Sasha.

Sasha (Xafari Support)Agent

Hello,
DevExpress has released new version v2015 vol 2.8 of product and hotfix where the issue is fixed: ASPxCriteriaPropertyEditor throws CannotResolveClassInfoException if an abstract DC interface is selected as the data type.

Feel free to contact us if you need further assistance or have additional questions.
Best regards,
Sasha.

× This ticket is closed.

Write US