简体   繁体   English

加载事件未触发

[英]Load event not firing

I am rebuilding a project that I originally coded in SharpDevelop in Visual Studio. 我正在重建一个最初在Visual Studio中的SharpDevelop中编码的项目。 The relevant code worked in SharpDevelop. 相关代码在SharpDevelop中起作用。

The following steps should illustrate the problem: 以下步骤应说明该问题:

  1. Create a new project 创建一个新项目
  2. Add a reference to System.Data.SQLLite (I am using the DLL for .NET 4.5) 添加对System.Data.SQLLite的引用(我正在将DLL用于.NET 4.5)
  3. In the main form, add the using statement: 在主窗体中,添加using语句:

    using System.Data.SQLite; 使用System.Data.SQLite;

  4. In the form's Load event, attach the event handler 在表单的Load事件中,附加事件处理程序

      private void PriceType2_Load(object sender, EventArgs e) { MessageBox.Show("Load event hNDLER"); SQLiteConnection con; //con = new SQLiteConnection(); } 

That works, but if you uncomment the next line, it doesn't. 那行得通,但是如果您取消注释下一行,那是行不通的。

        private void PriceType2_Load(object sender, EventArgs e)
    {
        //SetDisableColors();
        //ToggleEnableOff();
        MessageBox.Show("Load event");
        SQLiteConnection con;
        con = new SQLiteConnection();

    }

The form opens, but the message box is not displayed. 窗体打开,但不显示消息框。 As I said, it works fine in SharpDevelop. 如我所说,它在SharpDevelop中可以正常工作。 And in case you're wondering, I am migrating the project because I need a grown up Report Viewer. 如果您想知道,我正在迁移项目,因为我需要一个长大的Report Viewer。

Any ideas? 有任何想法吗?

I just changed the reference to the assembly for .NET 4.0 (although my dev machine and all my others have 4.5) and it works. 我只是更改了对.NET 4.0程序集的引用(尽管我的开发机和我的所有其他机器都有4.5),并且它可以工作。 I remembered reading somewhere that there was an issue with the 4.5 DLL, but I don't know what it was. 我记得在某处读到4.5 DLL出现问题,但我不知道这是什么。

Thanks for all the pointers. 感谢所有的指针。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM