System.ObjectDisposedException
quando lo stile tasto è impostato su FlatStyle.System
in applicazione WinFormsSystem.ObjectDisposedException quando lo stile tasto è impostato su FlatStyle.System in applicazione WinForms
Ho un form figlio, che si presenta sulla clic su un pulsante nel genitore . E il codice va come sotto.
Public Class Parent
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub btnOpenChild_Click(sender As Object, e As EventArgs) Handles btnOpenChild.Click
Child.Show()
End Sub
End Class
Il modulo figlio ha a sua volta un pulsante che si chiude da solo.
Public Class Child
Private Sub btnCloseMe_Click(sender As Object, e As EventArgs) Handles btnCloseMe.Click
Me.Close()
End Sub
End Class
passaggi per ottenere un'eccezione:
- In modalità di debug, mettere un punto di rottura sulla
Me.Close()
- Quindi fare clic sul pulsante di chiusura del bambino.
- Sul colpo del punto di rottura aprire il blocco note e
- Comeback alla soluzione poi continuare
Eccezione:
System.ObjectDisposedException was unhandled
HResult=-2146232798
Message=Cannot access a disposed object.
Object name: 'Button'.
Source=System.Windows.Forms
ObjectName=Button
StackTrace:
at System.Windows.Forms.Control.CreateHandle()
at System.Windows.Forms.Control.get_Handle()
at System.Windows.Forms.Control.PointToScreen(Point p)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.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(ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at WindowsApplication2.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
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:
Qualcuno ha qualche idea, ciò è esplicitamente giunto il momento in stile tasto impostato su FlatStyle.System
È questo che causa un problema nella vostra applicazione o solo curiosità? –
Nella mia applicazione realtime su click close c'è un processo di lunga durata che va per almeno 10-15 secondi. Nel frattempo se l'utente fa clic su qualsiasi altra applicazione come notepad o documento word o chrome, viene visualizzato questo errore. –
Debugging UI ha un talento per causare problemi come questo. Un'interruzione del debugger in sé ha modo di far sì che gli eventi si attivino in modo diverso, può causare eventi di messa a fuoco e pittura. In questo caso, l'attivazione di un altro processo è il trigger. Presumo che abbia qualcosa a che fare con la proprietà Capture, fondamentale per i pulsanti. In casi estremi può essere necessario utilizzare il debugger remoto in modo che il debugger non possa influenzare l'interfaccia utente. Questo non è un caso estremo, semplicemente non avviando Blocco note è la soluzione alternativa. Continua a guidare. –