Getting the following error in Visual Studio 2017 using a Windows form on Windows 7. This happens on multiple computers. I have a set of editboxes within labels all set to hide or go visible when selecting a "form" in a combobox. What happens is I import text into these editboxes, wheel scroll or up/down arrows through the form combobox selecting the different labels to display or hide, when doing this eventually the editbox in one of these forms goes blank. When you go to type in the editbox you get the memory error. I've searched and searched for a solution with no luck. Any help would be really appreciated.
System.AccessViolationException occurred
HResult=0x80004003
Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Source=System.Windows.Forms
StackTrace:
at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
at System.Windows.Forms.Control.DefWndProc(Message& m)
at System.Windows.Forms.Control.WmKeyChar(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.TextBoxBase.WndProc(Message& m)
at System.Windows.Forms.TextBox.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 Notes.Program.Main() in documents\visual studio 2017\Projects\Notes\Notes\Program.cs:line 19
The code for the import of the editbox that goes blank.
List<string> ort = imp.Split(new[] { Environment.NewLine }, StringSplitOptions.None).ToList();
//Name regex match
var match = new Regex(@"((?<=: ).*(?=\[))");
var name = match.Match(ort[0]);
if (tChoice == 0) { user.Text = String.Empty; user.AppendText(name.Groups[0].ToString()); }
if (tChoice == 1) { pwuser.Text = String.Empty; pwuser.AppendText(name.Groups[0].ToString()); }
if (tChoice == 2)
{
gmmuser.Text = String.Empty; requser.Text = String.Empty; reqAuser.Text = String.Empty; billuser.Text = String.Empty;
gmmuser.AppendText(name.Groups[0].ToString()); requser.AppendText(name.Groups[0].ToString()); reqAuser.AppendText(name.Groups[0].ToString()); billuser.AppendText(name.Groups[0].ToString());
}
if (tChoice == 3) { emailuser.Text = String.Empty; emailuser.AppendText(name.Groups[0].ToString()); }
It actually looks like it might have something to do with the target framework. I had it set to 4.6.2. I set it to 4.5.2 and have yet to come across the issue, fingers crossed.
User contributions licensed under CC BY-SA 3.0