ArgumentException 未处理 Application.run
您好,我浏览了很多网站,但似乎找不到答案。
我修改了一个连接到通过 C# Winforms 应用程序上的表适配器连接的 Datagridview 的视图,为了“重新连接”,我必须删除表适配器并重新连接它。这是为了消除有关唯一约束的错误。所以我修复了这个问题,现在应用程序启动,但是当我单击该网格所在的选项卡时,我得到:
System.ArgumentException was unhandled
Message="Cannot bind to the property or column Id on the DataSource.\r\nParameter name: dataMember"
Source="System.Windows.Forms"
ParamName="dataMember"
StackTrace:
at System.Windows.Forms.BindToObject.CheckBinding()
at System.Windows.Forms.BindToObject.SetBindingManagerBase(BindingManagerBase lManager).........
我似乎找不到这个问题的答案。有人可以帮助我吗?
谢谢
Hi I've been through many sites and can't seem to find an answer.
I modified a view that was connected to a Datagridview connected through a tableadapter on a C# Winforms app and in order to "reconnect" I had to delete the tableadapter and reconnect it. This was to get rid of an error regarding Unique contstraints. So I fixed that and now the application launches but when I click on the tab that that grid is on I get:
System.ArgumentException was unhandled
Message="Cannot bind to the property or column Id on the DataSource.\r\nParameter name: dataMember"
Source="System.Windows.Forms"
ParamName="dataMember"
StackTrace:
at System.Windows.Forms.BindToObject.CheckBinding()
at System.Windows.Forms.BindToObject.SetBindingManagerBase(BindingManagerBase lManager).........
I can't seem to find an answer to this problem. Can someone help me?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
首先,我从这篇文章的标题中注意到,您在 application.Run 中看到了此异常,这意味着它可能被抛出到调用堆栈的更高位置。您可以转到菜单上的“调试”->“异常”并将其设置为“抛出异常时中断”吗?这将帮助您在发生这种情况时准确隔离。听起来好像有绑定信息设置,并且您删除了网格尝试绑定到的属性之一。
First, I noticed from the title of this post you are seeing this exception at application.Run which means it probably got thrown a lot higher up the callstack. Can you go to Debug->Exceptions on the menu and set to Break on exceptions when thrown. This will help you isolate exactly when this is happening. It sounds like there is binding information setup and you remeoved one of the properties the grid is trying to bind to.
我已经解决了这个问题,尽管我不喜欢我的解决方案。我再次删除了TableAdapter并重新命名了这次。然后我重命名了原始名称的所有实例(所有 192 个实例,即使我删除了适配器并重新创建,其中仍然有 192 个实例!然后我必须修复查询,因为我已经重命名了所有实例并且使用了视图名作为 TableAdapter 名称,因为它是默认名称。希望这对某人有帮助。
I have solved the issue though I don't like my solution. I deleted the TableAdapter again and renamed it this time. Then I renamed all instances of the original name (all 192 of them even though I had deleted the adapter and recreated there were 192 of them still around! I then had to fix the query because I had renamed all the instances and I used the viewname as the TableAdapter name as it was the default. Hope this helps someone.
如果更改网格或视图中的架构并引用不再存在的字段,您将得到:
System.ArgumentException : Cannot bind to the property or column Id on the DataSource.Parameter name: dataMember
The column name that you are缺失列在单词列之后。我错过了“ID”栏。我以为我无法绑定到属性或列 ID,例如。我读到了错误。解决了其他人遇到相同问题无法绑定到列的问题
专辑。
我认为如果错误来自更接近网格构建代码而不是 Application.Run 的地方,我可能已经看到了它。也许即使它在将网格/文本框绑定到 ID 字段时出错,我也会看到它尝试对 ID 字段执行某些操作,并发现它不在那里。哎哟 :-)
If you change the schema on a grid or within a view and refer to a field that no longer exists you get:
System.ArgumentException : Cannot bind to the property or column Id on the DataSource.Parameter name: dataMember
The column name that you are missing is listed after the word column. I was missing the column "ID". I thought I was unable to bind to the property or column Id eg. I read the error. Solved from someone else having the same issue being unable to bind to column
ALBUM.
I think if the error had come from somewhere closer to the Grid building code instead of Application.Run I may have seen it. Maybe even if it errored at the binding of the grid / text box to the ID field I would have seen it trying to do something with the ID field and figured out it wasn't there. Oy Vay :-)