You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

XAF更新模型时CustomAttributeFormatException错误排查求助

解决更新Model.DesignedDiffs.xafml时的CustomAttributeFormatException错误

问题根因

更新Model.DesignedDiffs.xafml时触发的CustomAttributeFormatException(初始提示“指定自定义属性的二进制格式无效”),实际根源是非持久化DomainComponent上的ConditionalAppearance属性参数类型不匹配:你误用了System.Drawing.FontStyle枚举,而DevExpress AppearanceAttribute的FontStyle参数要求的是DevExpress.ExpressApp.ConditionalAppearance.AppearanceFontStyle枚举,导致设计时反射解析属性参数失败,触发“未找到FontStyle属性”的内层错误。

修复步骤

  1. 替换枚举类型:将代码中的FontStyle = FontStyle.Regular替换为FontStyle = AppearanceFontStyle.Regular
  2. 添加必要命名空间:确保DomainComponent类文件顶部引用ConditionalAppearance命名空间

修复后的代码示例

using DevExpress.ExpressApp.ConditionalAppearance;
using DevExpress.ExpressApp.DC;

[DomainComponent]
[Appearance("ToDoGreen", FontStyle = AppearanceFontStyle.Regular, BackColor = "#D9EAD3", TargetItems = "*", Criteria = "true", Context = "ListView")]
public class YourDomainComponent
{
    // 业务属性定义
}

补充说明

初始错误日志中的“二进制格式无效”是反射解析自定义属性时的外层包装错误,实际触发点是后续定位到的枚举类型不匹配问题——设计时环境无法识别传入的System.Drawing.FontStyle与AppearanceAttribute预期的参数类型,进而抛出属性未找到的异常。

内容的提问来源于stack exchange,提问作者Kirsten

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.06 18:18:14