From 075a3a1df6baf1f43e9ae427d97bcba149c439fb Mon Sep 17 00:00:00 2001 From: Ahmet Sait Date: Thu, 11 Dec 2025 13:55:17 +0100 Subject: [PATCH] Prevent AccessViolationException with IsDisposed check --- Scintilla.NET/Scintilla.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Scintilla.NET/Scintilla.cs b/Scintilla.NET/Scintilla.cs index 1fdfe7c..c093363 100644 --- a/Scintilla.NET/Scintilla.cs +++ b/Scintilla.NET/Scintilla.cs @@ -987,6 +987,9 @@ public IntPtr DirectMessage(int msg, IntPtr wParam) [EditorBrowsable(EditorBrowsableState.Advanced)] public virtual IntPtr DirectMessage(int msg, IntPtr wParam, IntPtr lParam) { + if (IsDisposed) + throw new ObjectDisposedException(!string.IsNullOrEmpty(Name) ? Name : nameof(Scintilla)); + // If the control handle, ptr, direct function, etc... hasn't been created yet, it will be now. return DirectMessage(SciPointer, msg, wParam, lParam); }