Exe behaves differently when I put in the startup folder

I have a C # utility that controls the database. This is for my own use - I did not create an installation package, but I installed the configuration for release. I pulled the .exe from the release folder, placed it on my desktop, double-clicked on it, and it worked fine.

The next logical step was to put it in the startup folder. The result was unexpected. Despite the code:

private void Form1_Shown(object sender, EventArgs e)
    {
        InitializeControls();
        this.Hide();
    }

The form was never hidden. Besides the fact that VS 2010 is launched. Does anyone understand why the behavior is different when I put .exe in the Startup folder v. Just double click it?

Notes. It connects to the database by pulling the connection string from the configuration file:

ConfigurationManager.ConnectionStrings["default"].ToString();

The only thing that contains the configuration file is the connection string, and I also add the configuration file to the startup folder. As for this, it just queries the database and fills in 7 or 8 labels in the form. It collapses into the system tray, starts every hour with a timer, but also has an update button.

+3
source share
1 answer

Most likely, your working directory is set incorrectly in the download file link file. So the application does not have the * .exe.config file (or did you just forget to copy it?).

0
source

All Articles