开发者

Eazfuscator. An error occurs when using the DataGridView control

开发者 https://www.devze.com 2023-03-07 20:26 出处:网络
my code is as follows: IList<Users> myData = new List<Users>(); myData = HelperUsers.GetUsersList(); // return IList<Users>

my code is as follows:

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.Inva开发者_运维问答lidate();

works perfectly still in debug, but when compiling as releace occurs following error "Object reference not set to an instance of an object." in the line:

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

Thanks


The Name property of your Users class is being renamed/obfuscated. Therefore the Columns collection doesn't have an entry for it.

Per the Eazfuscator you can do the following to disable class property renaming:

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

Or for a single property:

class MyOneThousandAndFourthClass {

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

}
0

精彩评论

暂无评论...
验证码 换一张
取 消