Greg Motter

Hello all,

I'm am trying to get a console app simply to run from within Visual Studio. I used to have VS configured for VB, but I reset it through the import/export wizard to c#

When I create the console app, my code is:

Code Snippet

namespace ConsoleApplication2

{

class Program

{

static void Main(string[] args)

{

//Hello World to Console hopefully

Console.WriteLine("Hello World!");

Console.ReadKey();

}

}

}

However when i then run it, I do not get a console and I get the following output:

'ConsoleApplication2.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.

'ConsoleApplication2.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities\8.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.

'ConsoleApplication2.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.

'ConsoleApplication2.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.

'ConsoleApplication2.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Drawing\2.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.

'ConsoleApplication2.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities.Sync\8.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.Sync.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.

'ConsoleApplication2.vshost.exe' (Managed): Loaded 'C:\Documents and Settings\Rhumba\My Documents\Visual Studio 2005\Projects\BegVCSharp\Chapter2\ConsoleApplication2\ConsoleApplication2\bin\Debug\ConsoleApplication2.vshost.exe', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.

'ConsoleApplication2.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_32\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.

'ConsoleApplication2.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.

The thread 0x15d0 has exited with code 0 (0x0).

The thread 0x15cc has exited with code 0 (0x0).

'ConsoleApplication2.vshost.exe' (Managed): Loaded 'C:\Documents and Settings\Rhumba\My Documents\Visual Studio 2005\Projects\BegVCSharp\Chapter2\ConsoleApplication2\ConsoleApplication2\bin\Debug\ConsoleApplication2.exe', Symbols loaded.

The program '[2016] ConsoleApplication2.vshost.exe: Managed' has exited with code -1073741819 (0xc0000005).

I've already uninstalled and reinstalled VS.

I'm guessing there is somehting easy I'm missing.


Thanks,

Greg



Re: Visual C# General Console App, but no console shows up.

Rashmi Gopinath

Try commenting out the Console.ReadKey() line and then try executing the code again.

Thanks,

Rashmi





Re: Visual C# General Console App, but no console shows up.

Greg Motter

Tried that an get the following:

'ConsoleApplication2.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.

'ConsoleApplication2.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities\8.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.

'ConsoleApplication2.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.

'ConsoleApplication2.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.

'ConsoleApplication2.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Drawing\2.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.

'ConsoleApplication2.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities.Sync\8.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.Sync.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.

'ConsoleApplication2.vshost.exe' (Managed): Loaded 'C:\Documents and Settings\Rhumba\My Documents\Visual Studio 2005\Projects\BegVCSharp\Chapter2\ConsoleApplication2\ConsoleApplication2\bin\Debug\ConsoleApplication2.vshost.exe', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.

'ConsoleApplication2.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_32\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.

'ConsoleApplication2.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.

The thread 0x11a8 has exited with code 0 (0x0).

The thread 0x166c has exited with code 0 (0x0).

'ConsoleApplication2.vshost.exe' (Managed): Loaded 'C:\Documents and Settings\Rhumba\My Documents\Visual Studio 2005\Projects\BegVCSharp\Chapter2\ConsoleApplication2\ConsoleApplication2\bin\Debug\ConsoleApplication2.exe', Symbols loaded.

The program '[5800] ConsoleApplication2.vshost.exe: Managed' has exited with code -1073741819 (0xc0000005).

Still no console, although I think i need the Console.Readkey(); to keep the console on screen. I even tried to add another writeline after the readkey and put a debug on it to get it to stay on screen, but it's not staying.




Re: Visual C# General Console App, but no console shows up.

Greg Motter

I just used Ctrl + F5 and it stays on screen. But it should work with the CONSOLE.READKEY() I would think

Still confused,

Greg





Re: Visual C# General Console App, but no console shows up.

Peter Ritchie

In your project's properties, in the Application tab, ensure the Application Type dropdown is set to Console Application.






Re: Visual C# General Console App, but no console shows up.

Greg Motter

I don't see an application type.

I do see an Output Type: which is set to Console Application.

And like I said if i do a Ctrl F5, it will go to the console app. It's almost like the Console.Readkey() is not working.

Greg





Re: Visual C# General Console App, but no console shows up.

Peter Ritchie

Sorry, yes that should have been Output Type, not Application Type. I can't reproduce what you're seeing when Output Type is set to Console Application.






Re: Visual C# General Console App, but no console shows up.

Greg Motter

Really odd. I just tried to create a Window's application with a button and one line of code on the button.

Console.WriteLine("Hello World!");

And even there I don't get the window's application form to come up after hitting F5.

Really odd. Hoping I don't need to reinstall the whole OS.

Greg





Re: Visual C# General Console App, but no console shows up.

Peter Ritchie

That's expected because a Windows Application doesn't create a Console window.






Re: Visual C# General Console App, but no console shows up.

Greg Motter

I was not expecting a console app from the window's app. I was just expecting the form with one button on it to give me a Hello World MessageBox when I clicked it.

But I'm getting nothing when I hit f5. It does not even enter debugger.

Greg





Re: Visual C# General Console App, but no console shows up.

Peter Ritchie

Why would you get a hello world message box from the following code:

Code Snippet

Console.WriteLine("Hello World");






Re: Visual C# General Console App, but no console shows up.

Greg Motter

I'm sorry. I got typing too fast.

It's actually MessageBox.WriteLine("Hello World");

Greg





Re: Visual C# General Console App, but no console shows up.

Greg Motter

And let me simplify it even more.

I did the following:

1) Created a new Windows Application. So only Form1 is on screen.

2) Added no code at all to it. Added no buttons.

3) I simply hit F5. Which at least in VB would launch the application and give me an empty form.

In C# it is doing nothing. It simply goes right back to the form. It's like something kicks it out of debugger. But unlike Ctrl F5 with the console app. It does not help with the window's app.

Hope that helps,

Greg





Re: Visual C# General Console App, but no console shows up.

Peter Ritchie

I'll assume, MessageBox.Show("Hello World")...

With a brand new project, MessageBox.Show("...") shows nothing either

Try repairing you .NET installation: run Add/Remove Programs, select Microsoft .NET Framework 2.0, click Change, select Repair. Reboot and see if that helps.






Re: Visual C# General Console App, but no console shows up.

Michael L. White

Hi Greg,

the difference here, is that a window application has differnt ways of interacting then a console app would.

For instance, in a windows application, you would use the MessageBox object to present a message

(using C# because I'm fun that way)

MessageBox.Show("Hello World");

If your console application is not running, did you start off with a console app