Eazfuscator。使用DataGridView控件时出现错误
我的代码如下:
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";
谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的 Users 类的 Name 属性正在被重命名/混淆。因此 Columns 集合没有对应的条目。
根据 Eazfuscator,您可以执行以下操作来禁用类属性重命名:
或者对于单个属性:
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: