C# LINQ中的Datacontext&引用;“在当前上下文中不存在”;

C# LINQ中的Datacontext&引用;“在当前上下文中不存在”;,c#,.net,winforms,linq-to-sql,C#,.net,Winforms,Linq To Sql,我一直收到这个错误消息。我按照指示做了,但它似乎仍然不起作用?解决这个问题的办法是什么?这是我的密码 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Da

我一直收到这个错误消息。我按照指示做了,但它似乎仍然不起作用?解决这个问题的办法是什么?这是我的密码

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.Linq;
using System.Data.Linq.Mapping;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            MyDatabaseDataContext = new MyDatabaseDataContext(@"C:\Users\John\Documents\visual studio 2010\Projects\WindowsFormsApplication1\WindowsFormsApplication1\MyDatabase.mdf");
        }


    }
}
这是stacktrace

Error   1   'WindowsFormsApplication1.Form1' does not contain a definition for 'Form1_Load' and no extension method 'Form1_Load' accepting a first argument of type 'WindowsFormsApplication1.Form1' could be found (are you missing a using directive or an assembly reference?)   C:\Users\John\Documents\Visual Studio 2010\Projects\WindowsFormsApplication1\WindowsFormsApplication1\Form1.Designer.cs 92  55  WindowsFormsApplication1

如果在设计器中添加事件处理程序,然后删除处理程序方法,则会发生这种情况。 由于没有删除将方法添加到事件中的自动生成代码,因此会出现编译器错误


转到
.Designer.cs
文件并删除有错误的行。

能否发布完整的堆栈跟踪。InitializeComponent中生成了什么?你有什么例外?