Posted By: JScript | Aug 4th, 2005 @ 11:04 AM
page 1 of 1
Comments: 7 | Views: 2188
JScript
JScript
Way to go.

Hmm, "Specified cast is not valid" error: only when compiled with /fast off.


import System;
import System.Windows.Forms;


Application.Run(new EventTestForm);


class EventTestForm extends Form
{
   function EventTestForm()
   {
      var button : Button = new Button;

      button.Text = "click";

      Controls.Add(button);

      try
      {
         button.add_Click(this.clicky);
      }
      catch(er)
      {
         MessageBox.Show(er.message,"Error!",MessageBoxButtons.OK,MessageBoxIcon.Error);

         MessageBox.Show("clicky is a " + typeof this.clicky);
      }
   }


   function clicky(obj, evt : EventArgs)
   {
      MessageBox.Show("clicky is a " + typeof this.clicky);
   }
}

That's basically this example; strange...

Roobin
Roobin
My 1303S
Does it make any difference if you move:

Application.Run(new EventTestForm);

to the end of the script?

Sven Groot
Sven Groot
You can't have everything; after all, where would you put it?
Could you use ILDASM and post the generated IL code for the function both with and without /fast?