System.AccessViolationException: Attempted to read or write protected memory.

i get this exception when i change a multiline textbox to single line: Visual studio actually throws the exception at the Program.cs at the Application.Run(new Form1()); line, but i found that the issue is caused by the line valTxtBox.Multiline = false; because if i remove it i dont get the exception What is going on here?
cs
valTxtBox.TextChanged += (_, _2) =>
{
if (valTxtBox.Text.Contains('\n'))
{
disableTxtBoxAutoClose = true;
valTxtBox.Multiline = true;
valTxtBox.Height = 20 + 100;
valTxtBox.Focus();
disableTxtBoxAutoClose = false;
}
else
{
disableTxtBoxAutoClose = true;
valTxtBox.Multiline = false; <<-PROBLEM CAUSED BY THIS?
valTxtBox.Focus();
valTxtBox.Text = boxText;
disableTxtBoxAutoClose = false;
}
cs
valTxtBox.TextChanged += (_, _2) =>
{
if (valTxtBox.Text.Contains('\n'))
{
disableTxtBoxAutoClose = true;
valTxtBox.Multiline = true;
valTxtBox.Height = 20 + 100;
valTxtBox.Focus();
disableTxtBoxAutoClose = false;
}
else
{
disableTxtBoxAutoClose = true;
valTxtBox.Multiline = false; <<-PROBLEM CAUSED BY THIS?
valTxtBox.Focus();
valTxtBox.Text = boxText;
disableTxtBoxAutoClose = false;
}
3 Replies
HtmlCompiler
HtmlCompiler5mo ago
is there more in the call stack of the exception?
Diesel Geezer
Diesel GeezerOP5mo ago
no just this
Diesel Geezer
Diesel GeezerOP5mo ago
No description
Want results from more Discord servers?
Add your server