Yorkiebar14 0 Junior Poster in Training


I'm facing an issue where my code is working inside Visual Studio, but failing when I build the application and run it. I have tried Googling for code alternatives to where I've tracked the bug down to, and I can't find anything that works the way I need it to.

Here is my code:

this.console.addLine("Create Notification invoked: " + mainForm.IsHandleCreated.ToString());
            mainForm.BeginInvoke((MethodInvoker)delegate() {
                Notification noti = new Notification();
                this.console.addLine("Creating notification ID... " + noti.GetHashCode().ToString());

(console.addLine is a custom output method, which works).

So when I run the application inside Visual Studio I get the first line of "Create Notification invoked: True", then I get a line which says "Started" and it all works fine. But if I build the application and run it outside of Visual Studio, I only get the first line "Create Notification invoked: True". I don't get the "Started" line, and it doesn't create the new Notification form instance.

Help is greatly appreciated,

I should probably also mention that 'mainForm' is set to a new Form1 (startup form);
public static Form1 mainForm = new Form1();

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.