BabaJaga
BabaJaga

Reputation: 59

MessageBox.Show() does not work outside debug

I'm new to C# and Visual Studio. I wrote a simple forms app that works great in debug. When I build and run the exe everything works except MessageBox.Show() does not pop up any message. So I built a new project with one form, one button, and one event handler.

Sure enough. The message box pops up when using Start With Debugging.

Nothing happens when I click the button with using Start Without Debugging.

Some research pointed me at:

[ComVisibleAttribute(true)]
public enum UIPermissionWindow { AllWindows }

I added that and still not pop-up from any message boxes. The project is as basic as possible for troubleshooting.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

[ComVisibleAttribute(true)]
public enum UIPermissionWindow { AllWindows }

namespace Form462
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e) => MessageBox.Show("Help!");
    }
}

Upvotes: 0

Views: 627

Answers (2)

BabaJaga
BabaJaga

Reputation: 59

Turned out this was due to another process blocking all pop-ups on the machine.

Upvotes: 0

BabaJaga
BabaJaga

Reputation: 59

Windows corruption is clearly the culprit. MessageBox.Show() works perfectly normal on another server. One other odd thing on this server, Can't seem to open dialog boxes in Visual Studio. File --> Open ---> New Project Solution.

Nothing happens. I see the little Ready Icon in the way bottom left blink, nothing else happens. I have no updates for Visual Studio or windows.

Upvotes: 1

Related Questions