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.Invalidate();
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:
Or for a single property: