I just created small project containing a form -- it works Ok either as form or as executable. It's really hard to say what could work wrong in you code.
Form.Initthis.tray.addicontoiconlist("tree.ico")
Form.ShowIcon && attached to command buttonthis.tray.addicontosystray()
Form.HideIcon && attached to command buttonthis.tray.removeiconfromsystray()