c# - 打开解决方案时,Visual Studio 2017卡住并崩溃

标签 c# visual-studio crash

我有一个C#项目(WinForms),语法略有错误,当我尝试打开它时,Visual Studio立即冻结,然后退出/崩溃。
我认为它与System.Windows.Input.KeyEventHandler有关,因为如果不包含它,它就不会崩溃。

我没有包含的System.Windows.Input.KeyEventHandler,并且没有崩溃。但是我不知道为什么它会因为包含的System.Windows.Input.KeyEventHandler而崩溃。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Input;

namespace hiddenform
{
    public partial class Form1 : Form
    {
        static hide hide = new hide();
        public event System.Windows.Input.KeyEventHandler keyhandler = new System.Windows.Input.KeyEventHandler(hide.handlekeys);

        public Form1()
        {
            InitializeComponent();

        }
    }
}

我只是不知道为什么当我包含System.Windows.Input.KeyEventHandler时VS2017会崩溃。它也没有与System.Windows.Forms.KeyEventHandler崩溃。

如果需要,您还可以在Github上找到完整的解决方案。

最佳答案

System.Windows.Input.KeyEventHandler是通常在表单的“设计器”中设置的方法,请尝试在该方法中实现,这样可以解决您的问题!

关于c# - 打开解决方案时,Visual Studio 2017卡住并崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54328623/

相关文章:

windows - 尝试使用 WinDbg : PEB is Paged Out, 分析转储文件不会加载符号

c# - 删除实体集合中的项目

c# - DbContext 已被处置(ASP.NET MVC)

c++ - Visual Studio - 调用堆栈不会追溯到用户函数

c++ - 将初始化列表与 std::map 一起使用

android - 如何修复损坏的应用程序?

ios - NSUserDefaults setObject 在线程中崩溃

c# - 使用 Roslyn 编译程序集时出现 FileNotFoundException

c# - 正则表达式替换越来越多

visual-studio - 文字高亮视觉辅助x