C#保护记忆错误慢慢扼杀了我的大脑

C#保护记忆错误慢慢扼杀了我的大脑,c#,visual-studio,C#,Visual Studio,在Windows 7上使用Windows窗体在Visual Studio 2017中获取以下错误。这在多台计算机上发生。我在标签中有一组编辑框,当在组合框中选择“表单”时,所有编辑框都设置为隐藏或可见。我将文本导入这些编辑框,通过表单组合框滚动或向上/向下箭头,选择要显示或隐藏的不同标签,这样做最终会使其中一个表单中的编辑框变为空白。当您在编辑框中输入时,会出现内存错误。我一直在寻找一个解决方案,但运气不好。任何帮助都将不胜感激 System.AccessViolationExcepti

在Windows 7上使用Windows窗体在Visual Studio 2017中获取以下错误。这在多台计算机上发生。我在标签中有一组编辑框,当在组合框中选择“表单”时,所有编辑框都设置为隐藏或可见。我将文本导入这些编辑框,通过表单组合框滚动或向上/向下箭头,选择要显示或隐藏的不同标签,这样做最终会使其中一个表单中的编辑框变为空白。当您在编辑框中输入时,会出现内存错误。我一直在寻找一个解决方案,但运气不好。任何帮助都将不胜感激

    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
输入为空的编辑框的代码

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()); }
List-ort=imp.Split(new[]{Environment.NewLine},StringSplitOptions.None);
//名称正则表达式匹配

var match=新正则表达式(@“((?它实际上看起来可能与目标框架有关。我将其设置为4.6.2。我将其设置为4.5.2,但尚未遇到问题,祈祷好运。

它实际上看起来可能与目标框架有关。我将其设置为4.6.2。我将其设置为4.5.2,但尚未遇到问题,fingers交叉。

我们能看到一些代码吗?您能提供一个复制问题的最小示例吗?我们也可以从查看鼠标滚轮和上下事件处理程序开始。我没有鼠标滚轮的设置,只要处理程序的话。我甚至不知道代码的哪个部分造成了这个问题。这看起来是一个一般性错误,我不知道如何确定确切的原因。您是否进行了任何p/invoke调用?开始从应用程序中删除内容,直到问题消失。然后您至少缩小了范围。然后…向我们显示代码。“这种情况在多台计算机上发生”?您是指您在其他使用dev Environment VS 2017和windows的计算机上尝试过这种方法吗?还是你是说其他机器向服务器请求?几乎可以肯定,这不是你显示的代码,你之前做了一些花哨的/错误的事情,并在某个地方丢弃了一个堆栈或堆,我们可以在哪里看到一些代码?你能提供一个再现该问题的最小示例吗?让我们先看看鼠标滚轮和上下事件处理程序。我没有任何使用鼠标滚轮设置的操作程序。我甚至不确定是哪部分代码导致了此问题。这似乎是一个一般性错误,我不知道从何处找出确切原因。是否进行了任何p/invoke调用?开始从应用程序中删除内容,直到问题消失。然后至少缩小了范围。然后…向我们展示代码。“这种情况会发生在多台计算机上”?你是说你在其他使用dev Environment VS 2017和windows的机器上尝试过这种情况吗?还是说其他机器请求服务器?几乎可以肯定,这不是你展示的代码,你之前做了一些花哨的/错误的事情,并在某个地方破坏了堆栈或堆