Eazfuscator. Error using 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.Invalidate(); 

It works fine when debugging, but when compiling as release, the following error occurs: "The reference to the object is not installed in the object instance." in line:

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

thanks

+7
source share
1 answer

The Name property of your Users class is renamed / obfuscated. Therefore, the Columns collection has no entry for it.

In Eazfuscator, you can do the following to disable the renaming of class properties:

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

Or for one property:

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

All Articles