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

Confuser混淆报错及ComboBox数据显示异常问题求助

解决Confuser混淆报错与ComboBox数据显示异常问题

一、Confuser运行报错:"Feature property cannot be set when Exclude is true"

报错原因

代码中ObfuscationAttribute同时设置Exclude = true和Feature = "renaming"违反Confuser规则:当Exclude=true时,该元素已被排除所有混淆处理,指定Feature参数无意义,触发参数异常。

修复方案

修改C#代码中的ObfuscationAttribute,移除多余的Feature参数,仅保留Exclude = true即可排除该类及属性的所有混淆:

[Obfuscation(Exclude = true)]
public class wdokum
{
    [Obfuscation(Exclude = true)]
    public string wsifdokd { get; set; }
    [Obfuscation(Exclude = true)]
    public string wnazivdok { get; set; }
    [Obfuscation(Exclude = true)]
    public string wdoknaz { get; set; }
    [Obfuscation(Exclude = true)]
    public string wpdvkolond { get; set; }
}

如果仅需排除重命名保护(允许其他混淆),可简化为:

[Obfuscation(Exclude = false, Feature = "renaming", ApplyToMembers = true)]
public class wdokum
{
    public string wsifdokd { get; set; }
    public string wnazivdok { get; set; }
    public string wdoknaz { get; set; }
    public string wpdvkolond { get; set; }
}

二、ComboBox7下拉数据被混淆显示异常

问题原因

ComboBox通过DisplayMember = "wdoknaz"绑定属性,若wdoknaz被重命名,运行时无法找到该属性,导致显示异常。

修复方案

  1. 确保wdokum类及属性的重命名被排除(按照上述代码修改)。
  2. 修正Confuser配置文件的语法错误,并添加针对wdokum类的重命名排除规则,避免全局规则覆盖:
<project outputDir="D:\RIS DEMO\RIS 768\RIS\RIS\obj\ConfuserEx\ZASTICEN RIS DEMO\Confused" 
        baseDir="D:\RIS DEMO\RIS 768\RIS\RIS\obj\ConfuserEx\ZASTICEN RIS DEMO"
        xmlns="http://confuser.codeplex.com">
  <!-- 全局默认混淆规则 -->
  <rule pattern="true" inherit="false">
    <protection id="anti debug" />
    <protection id="anti dump" />
    <protection id="anti tamper" />
    <protection id="anti ildasm" />
    <protection id="ctrl flow" />
    <protection id="ref proxy" />
    <protection id="invalid metadata" />
    <protection id="harden" />
    <protection id="rename" />
    <protection id="typescramble" />
    <protection id="constants" />
  </rule>
  <!-- 排除wdokum类及其成员的重命名 -->
  <rule pattern="type == 'RIS.KNJNALOGA/wdokum'" inherit="true">
    <protection id="rename" action="remove" />
  </rule>
  <module path="RIS Program.exe" />
</project>
  1. 优化数据绑定代码,用nameof替代硬编码属性名,避免因属性名变更出错:
comboBox7.DisplayMember = nameof(wdokum.wdoknaz);

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.13 13:57:05