Eazfuscator。使用DataGridView控件时发生错误

时间:2011-05-20 17:33:31

标签: c# winforms datagridview eazfuscator

我的代码如下:

IList<Users> myData = new List<Users>();

myData = HelperUsers.GetUsersList(); // return IList<Users>

BindingSource bsUsers = new BindingSource { DataSource = myData };
dataGridViewUsers.DataSource = bsUsers;

dataGridViewUsers.Columns["Name"].HeaderText = "Name";
dataGridViewUsers.Columns["LastName"].HeaderText = "Last name";

dataGridViewUsers.Invalidate();

仍可在调试中完美地工作,但在错误“对象引用未设置为对象的实例”之后发生重新编译时。在行:

dataGridViewUsers.Columns["Name"].HeaderText = "Name";

由于

1 个答案:

答案 0 :(得分:9)

正在重命名/混淆Users类的Name属性。因此,Columns集合没有条目。

根据Eazfuscator,您可以执行以下操作以禁用类属性重命名:

[System.Reflection.ObfuscationAttribute(Feature = "properties renaming")]
class MyOneThousandAndThirdClass {
    // ...
}

或者对于单个属性:

class MyOneThousandAndFourthClass {

    [System.Reflection.ObfuscationAttribute(Feature = "renaming")]
    public string DisplayName
    {
        get;
        set;
    }

}