Eazfuscator. An error occurs when using the DataGridView control
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;
}
}
精彩评论