O
O
Oleksandr2016-02-11 11:58:45
C++ / C#
Oleksandr, 2016-02-11 11:58:45

Why does it throw a NullReferenceException when accessing base?

Sometimes a NullReferenceException message is thrown in a class inherited from TreeView when accessing base.
How is this even possible and how to fix it?
Thank you.

protected override void WndProc(ref Message m)
        {
            if (m.Msg == WM_ERASEBKGND)
            {
                m.Result = IntPtr.Zero;
            }
            else if (this.ExpandSingleClick && m.Msg == WM_LBUTTONDBLCLK)
            {
                m.Result = IntPtr.Zero;
            }
            else
            {
                 base.WndProc(ref m); // Ошибка вылазит на этой строке
            }
        }
System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Windows.Forms.TreeView.CustomDraw(Message& m)
   at System.Windows.Forms.TreeView.WmNotify(Message& m)
   at System.Windows.Forms.TreeView.WndProc(Message& m)
   at Kstudio.Forms.ShellControls.TreeViewBase.WndProc(Message& m) in TreeViewBase.cs:line 215
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MonkAlex, 2016-02-11
@Track77

Falls not here, judging by a stack.
See

at System.Windows.Forms.TreeView.CustomDraw(Message& m)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question