C#Bunifu UI System.NullReferenceException未处理

Egy*_*MMM -1 c# user-interface button winforms bunifu

我正在使用Bunifu UI框架,一切都很好,直到我从Bunifu UI中添加了一个“退出”按钮,该按钮为bunifuFlatButton,我同时尝试了this.Close();。和Close(); 并与我都得到System.NullReferenceException是未处理的错误。

按键:

在此处输入图片说明

错误:

在此处输入图片说明

System.NullReferenceException was unhandled
  HResult=-2147467261
  Message=Object reference not set to an instance of an object.
  Source=Bunifu_UI_v1.5.3
  StackTrace:
       at Bunifu.Framework.UI.BunifuFlatButton.method_5()
       at Bunifu.Framework.UI.BunifuFlatButton.BunifuFlatButton_MouseClick(Object sender, MouseEventArgs e)
       at System.Windows.Forms.Control.OnMouseClick(MouseEventArgs e)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.Label.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at Project.Program.Main() in C:\Project\Project\Program.cs:line 19
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:
Run Code Online (Sandbox Code Playgroud)

谢谢

Fla*_*jta 5

我认为发生这种情况是因为Bunifu按钮具有某些方法,例如“悬停时更改颜色,单击鼠标时显示颜色等”,
当您单击按钮时,窗体关闭,但是也许应用程序尝试在该Bunifu按钮上调用一个方法,例如例如,在单击鼠标后更改颜色,但是该窗体已关闭,然后发生错误。
我通过在表单关闭之前禁用按钮来解决此问题:

private void bunifuFlatButton1_Click(object sender, EventArgs e)
{
    bunifuFlatButton1.Enabled = false;
    this.Close();
}
Run Code Online (Sandbox Code Playgroud)