简体   繁体   中英

Load event not firing

I am rebuilding a project that I originally coded in SharpDevelop in Visual Studio. The relevant code worked in 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)
  3. In the main form, add the using statement:

    using System.Data.SQLite;

  4. In the form's Load event, attach the event handler

      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. And in case you're wondering, I am migrating the project because I need a grown up 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. I remembered reading somewhere that there was an issue with the 4.5 DLL, but I don't know what it was.

Thanks for all the pointers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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