0

I have added an OpenFileDialog to my button (called "Browse") press event that should open a dialog, get a file name and return it to me.

using System;
using System.IO;
using System.Windows.Forms;

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

        private void button1_Click(object sender, EventArgs e)
        {
            string lastFileOpenPath = "";

            using (OpenFileDialog ofd = new OpenFileDialog())
            {

                ofd.Title = "Please choose the file";
                ofd.InitialDirectory = (Directory.Exists(lastFileOpenPath) ? lastFileOpenPath : @"C:\");

                string archiveExt = "";
                for (int cn = 1; cn <= 50; cn++)
                    archiveExt += (archiveExt == "" ? "" : ";") + "*." + cn.ToString().PadLeft(3, '0');
                ofd.Filter = "Archive File (*.rar)|*.rar|Archive Files (*.###)|" + archiveExt + "|All Supported Files (*.rar, *.###)|" + archiveExt + ";*.rar";

                ofd.FilterIndex = 3;
                ofd.RestoreDirectory = true;
                if (ofd.ShowDialog() == DialogResult.OK && File.Exists(ofd.FileName))
                {
                    FilePath.Text = ofd.FileName;
                    lastFileOpenPath = Path.GetDirectoryName(FilePath.Text);
                }
            }
        }
    }
}

For some reason any time I press my Browse button (even if I do nothing and hit cancel) and then try to close the form that's open, I get the following message in the Output window. The message does not appear if I open the form, then close it. It does appear if I open the form, click the Browse button, hit cancel and then close the form.

Assertion failed: Successful WSASTARTUP not yet performed (........\src\signaler.cpp:194)

Is it possible to account for this so the "error" (if it is an error) does not appear in the Output window? I'm not asking because it's annoying, I could care less of the message in a debug output window. I'm asking because of optimization.

Arvo Bowen
  • 4,524
  • 6
  • 51
  • 109
  • what is signaler.cpp?? is it a lib that you are using? why is there a c++ file in a c# win form project? – Steve Nov 26 '18 at 22:11
  • That's what is confusing to me as well... I have no clue what that is but it only shows up with I use the `OpenFileDialog` object. – Arvo Bowen Nov 26 '18 at 22:14
  • Do you have any Windows Explorer Add-Ins? This probably doesn't happen very often on other computers. – LarsTech Nov 26 '18 at 22:14
  • You think a program like `Google Backup and Sync` or `Insync` might be causing this error by chance? – Arvo Bowen Nov 26 '18 at 22:15
  • if you make a brand new winform project and try to do opendialog there does this still happen? if not then you need to look into what your current project is doing – Steve Nov 26 '18 at 22:16
  • Side note: Dialogs are a resource which should be disposed of. This applies to forms you use `ShowDialog()` to siplay as well as the stock NET ones. – Ňɏssa Pøngjǣrdenlarp Nov 26 '18 at 22:20
  • @Steve I just made a new project then added a textbox and button control and used the code in my question BEFORE I asked the question. – Arvo Bowen Nov 26 '18 at 22:23
  • @Disaffected1070452 I updated my original question to reflect that now. – Arvo Bowen Nov 26 '18 at 22:25
  • 2
    This comes up over and over again whenever programmers use one of the shell dialogs, like OpenFileDialog. You are no longer debugging your own program anymore, you get exposed to the many shell extensions that get loaded. Programmer machines tend to have a lot of them, not always of the best quality. While the assert is certainly one to be concerned about, pretty big eek on the health of your machine, you can squelch anything from a C++ source file by not enabling unmanaged debugging. SysInternals' AutoRuns utility to find/disable the evildoer. – Hans Passant Nov 26 '18 at 22:32
  • If you want to know where it comes from then [look here](https://github.com/zeromq/libzmq/blob/master/src/signaler.cpp#L192), might help to localize it quicker. – Hans Passant Nov 26 '18 at 22:34
  • Thanks @HansPassant. I have been looking for a reason to format my machine... I have noticed some really weird things going on (ex: Windows applications staying open in the background when I close them). – Arvo Bowen Nov 26 '18 at 23:17

0 Answers0