AccessViolationException on ToolTip that faults COMCTL32.dll - .NET 4.0

后端 未结 3 1507
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-30 04:58

We are having an issue with our Windows forms application where it is terminating due to an unhandled exception of type AccessViolationException that the stack trace is indi

相关标签:
3条回答
  • 2020-12-30 05:05

    According to MS, there is a known issue with the DataGrid control in certain situations, and the way to avoid this issue is to disable Tooltips for your DataGrid controls.

    We will be implementing the change and rolling it out to a pilot group in the next couple of days, I'll post back with success/failure in about a week (unless of course failure happens before then).

    The property to set according to MS is DataGridView.ShowCellToolTips = false;

    This fixed the issue for our application.

    To reproduce the issue, we needed to do the following:

    • Hover the mouse over a cell in our DataGridView that we knew would show a tooltip
    • Alt tab to another application (that will display on top of your application) before the tooltip is shown
    • Do not move the mouse
    • Alt tab back to our application
    • Our application crashes.
    0 讨论(0)
  • 2020-12-30 05:13

    It seems that setting DataGridView.ShowCellToolTips = false on Form.Deactivate prevents the crash. It can be reset to true on Form.Activate.

    The tooltip is still shown above the newly focused windows however - but I guess that's better then crashing.

    Or even better:

    The problem only occurs when visual styles are not enabled.

    Adding Application.EnableVisualStyles() in main() before any forms are instantiated solves the problem.

    0 讨论(0)
  • 2020-12-30 05:30

    more details https://github.com/Microsoft/dotnet/issues/402

    6 years later, solution is unfortunately still "use comctl v6"

    0 讨论(0)
提交回复
热议问题