9 Replies - 717 Views - Last Post: 24 February 2016 - 08:04 AM Rate Topic: -----

#1 luckie12  Icon User is offline

  • D.I.C Head

Reputation: -3
  • View blog
  • Posts: 234
  • Joined: 27-February 10

C# Windows Form Application freezing explorer on launch

Posted 24 February 2016 - 05:49 AM

Hello, i made a Windows Form application in C#, where cmd.exe is loaded into a textbox:
Posted Image

In debug, of the visual studio editor itself, the program works fully, like it has to..
But whenever i Build/Release it and try to start it from the explorer in the Release folder, my cursor gets this loading icon, but explorer is not freezing, the explorer freezes when i try to start the .exe with administrator rights > Rightclicking.
The program does come up in my processes list on Task Manager, but i am unable to force close it, as it does not go away.

What i have tried:
-Run this on my laptop > worked fully
-Get a error log from what goes wrong > Didnt work
-Tried to show up a message on form load > Nothing happens
-Put code in a button > Program still didnt

Does anyone know what the problem is?
This is my form load

        private void Form1_Load(object sender, EventArgs e)
        {
            this.AcceptButton = button1;
            MyProcess = new Process();
            var _with1 = MyProcess.StartInfo;
            _with1.FileName = "CMD.EXE";
            _with1.UseShellExecute = false;
            _with1.CreateNoWindow = true;
            _with1.RedirectStandardInput = true;
            _with1.RedirectStandardOutput = true;
            _with1.RedirectStandardError = true;
            MyProcess.Start();

            MyProcess.BeginErrorReadLine();
            MyProcess.BeginOutputReadLine();
            AppendOutputText("Process Started at: " + MyProcess.StartTime.ToLongDateString() + "\r\nTime: " + MyProcess.StartTime.ToLongTimeString());

        }



PS: If this is a PC sided problem, like my .NET , then excuse me for posting it here!

This post has been edited by luckie12: 24 February 2016 - 07:10 AM


Is This A Good Question/Topic? 0
  • +

Replies To: C# Windows Form Application freezing explorer on launch

#2 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 5884
  • View blog
  • Posts: 20,088
  • Joined: 05-May 12

Re: C# Windows Form Application freezing explorer on launch

Posted 24 February 2016 - 06:33 AM

Unfortunately, by choosing to put your code on the Form Load event, any exceptions that your code may throw is eaten by Windows if you are running on a 64-bit OS. I would try moving the code into a button click event handler or menu event handler to try to first see what exception may be thrown by the code when built in Release mode.

As alternative, do a file by file comparison of what is in your Debug folder and in your Release folder. You may have a missing dependency... like your MineCraft server or one of its dependencies.
Was This Post Helpful? 0
  • +
  • -

#3 maceysoftware  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 348
  • View blog
  • Posts: 1,493
  • Joined: 07-September 13

Re: C# Windows Form Application freezing explorer on launch

Posted 24 February 2016 - 06:35 AM

When your launching your application through debug do you have the immediate window open? no then open it!

When its launching does any messages appear in the immediate windows? like first chance exceptions?
Was This Post Helpful? 0
  • +
  • -

#4 luckie12  Icon User is offline

  • D.I.C Head

Reputation: -3
  • View blog
  • Posts: 234
  • Joined: 27-February 10

Re: C# Windows Form Application freezing explorer on launch

Posted 24 February 2016 - 06:51 AM

View PostSkydiver, on 24 February 2016 - 01:33 PM, said:

Unfortunately, by choosing to put your code on the Form Load event, any exceptions that your code may throw is eaten by Windows if you are running on a 64-bit OS. I would try moving the code into a button click event handler or menu event handler to try to first see what exception may be thrown by the code when built in Release mode.

As alternative, do a file by file comparison of what is in your Debug folder and in your Release folder. You may have a missing dependency... like your MineCraft server or one of its dependencies.



View Postmaceysoftware, on 24 February 2016 - 01:35 PM, said:

When your launching your application through debug do you have the immediate window open? no then open it!

When its launching does any messages appear in the immediate windows? like first chance exceptions?


1. I tried indeed (forgot to mention it) to have it on a own function called
void Console(){ <CODE HERE> }
bein called by the button
Still froze, second of that, the minecraft server does not get detected inside the script, people have to put
cd <minecraft server map> 
and follow up with starting the server.

I did what you said with the Immediate Window, its completely empty. i dont get any messages unfortunately

This post has been edited by luckie12: 24 February 2016 - 06:53 AM

Was This Post Helpful? 0
  • +
  • -

#5 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 5884
  • View blog
  • Posts: 20,088
  • Joined: 05-May 12

Re: C# Windows Form Application freezing explorer on launch

Posted 24 February 2016 - 07:19 AM

It froze where? On process start? On reading of error input? On reading of standard output? You could put a bunch of MessageBox's or use log4net to try to log what is happening to narrow down where things are hanging.

Or you could switch Visual Studio to Release builds and also try debugging there.
Was This Post Helpful? 0
  • +
  • -

#6 luckie12  Icon User is offline

  • D.I.C Head

Reputation: -3
  • View blog
  • Posts: 234
  • Joined: 27-February 10

Re: C# Windows Form Application freezing explorer on launch

Posted 24 February 2016 - 07:31 AM

View PostSkydiver, on 24 February 2016 - 02:19 PM, said:

It froze where? On process start? On reading of error input? On reading of standard output? You could put a bunch of MessageBox's or use log4net to try to log what is happening to narrow down where things are hanging.

Or you could switch Visual Studio to Release builds and also try debugging there.


It freezes on Process start, it shows nothing only :

Posted Image

It is in my processes, and my cursor changes to the loading cursor.
Was This Post Helpful? 0
  • +
  • -

#7 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 5884
  • View blog
  • Posts: 20,088
  • Joined: 05-May 12

Re: C# Windows Form Application freezing explorer on launch

Posted 24 February 2016 - 07:49 AM

There is no need to quote post above yours.

Yes, but where in your process is it hanging? This is where more detailed logging, or barring that going old school by putting in a bunch of MessageBoxes will help narrow down what is happening.

Also from that screenshot, it looks like you have multiple instances trying to run. Are you sure you don't have a mutex that is causing a deadlock?
Was This Post Helpful? 0
  • +
  • -

#8 luckie12  Icon User is offline

  • D.I.C Head

Reputation: -3
  • View blog
  • Posts: 234
  • Joined: 27-February 10

Re: C# Windows Form Application freezing explorer on launch

Posted 24 February 2016 - 07:56 AM

About that last part... No idea, im just wondering why it DOES work on my laptop but not on my desktop pc
Both have .net 4.6 and 4.5
Was This Post Helpful? 0
  • +
  • -

#9 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13482
  • View blog
  • Posts: 53,820
  • Joined: 12-June 08

Re: C# Windows Form Application freezing explorer on launch

Posted 24 February 2016 - 08:00 AM

There could be a host of issues.. security, permissions, file locations, or just plain differences between running in the test environment of the IDE compared to running alone.
Was This Post Helpful? 0
  • +
  • -

#10 luckie12  Icon User is offline

  • D.I.C Head

Reputation: -3
  • View blog
  • Posts: 234
  • Joined: 27-February 10

Re: C# Windows Form Application freezing explorer on launch

Posted 24 February 2016 - 08:04 AM

I will try the messageboxes, i have to restart my pc for that because i cant build, (process already running > Cant force close it)

EDIT: I've added a messagebox to form load, and build it in release, still nothing popsup, But after restarting my pc, and launching the program ONE time, i see that it made 3times WindowsXConsole.exe *32 processes instead of 1...

This post has been edited by luckie12: 24 February 2016 - 08:13 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1