PandaIII crash deploying - Ldr0

i would like to fire an Event when I press the Ldr0 button, so i have written the following Code:

public static void Main()
InterruptPort Ldr0 = new InterruptPort(FEZPandaIII.Gpio.Ldr0, false, Port.ResistorMode.PullUp, rt.InterruptMode.InterruptEdgeLevelLow);
Ldr0.OnInterrupt += new NativeEventHandler(Ldr0_OnInterrupt);

        SerialPort UART1 = new SerialPort("COM1", 115200);
        MotorController MController = new MotorController(UART1);


static void Ldr0_OnInterrupt(uint data1, uint data2, DateTime time)
OutputPort LED0 = new OutputPort(FEZPandaIII.Gpio.Led1, true);

So when I press the button the debug Crash with the following message:
The thread ‘’ (0x1) has exited with code 0 (0x0).

Waiting for debug commands…

The program ‘[6] Micro Framework application: Managed’ has exited with code 0 (0x0).

Does anybody know what’s going wrong ?

@ CS5798 - you have exited Main(). your program has stopped running. Add the following code at the end of Main:

you might also have a problem in your interrupt handler because you keep instaniating the led output port. create it in main and make it a static class variable.