locked
hello world RRS feed

  • Question

  • Hi everyone,

    Like every first time coder (or in my case, wannabe) I am trying to run the "hello world" exercise. I called it, Solo PR1 and I am using C# in VS 2015.

    But this is proving a bit tricky, my results differ a lot from the tutorial I am following.

    I haven't been here long enough to post images, I'll try and word the whole thing out. Sorry if the layout seems messy.

    Below is what I'm trying to run-

    using

    System;

    using

    System.Collections.Generic;

    using

    System.Linq;

    using

    System.Text;

    using

    System.Threading.Tasks;

    namespace

    Solo_PR1

    {

       

    public class Program

        {

           

    static void Main(string[] args)

            {

               

    Console.WriteLine("Hello World!");

            }

        }

    }

    These are my results, (dialogue box appears)-

    (dnx.exe) a problem caused the program to stop working correctly. Windows will close the program and notify you if a solution is available.

    The console window says this-

    Unhandled Exception: System.InvalidOperationException: Unable to load applicatio
    n or execute command 'Solo_PR1'. Available commands: Solo_PR1.
       at Microsoft.Framework.ApplicationHost.Program.ThrowEntryPointNotfoundExcepti
    on(DefaultHost host, String applicationName, Exception innerException)
       at Microsoft.Framework.ApplicationHost.Program.ExecuteMain(DefaultHost host,
    String applicationName, String[] args)
       at Microsoft.Framework.ApplicationHost.Program.Main(String[] args)
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at Microsoft.Framework.Runtime.Common.EntryPointExecutor.Execute(Assembly ass
    embly, String[] args, IServiceProvider serviceProvider)
       at dnx.host.Bootstrapper.RunAsync(List`1 args, IRuntimeEnvironment env)
       at dnx.host.RuntimeBootstrapper.ExecuteAsync(String[] args)
       at dnx.host.RuntimeBootstrapper.Execute(String[] args)
       at DomainManager.Main(Int32 argc, String[] argv)

    On the output side I get this (which is really confusing for me, Is the program saying I got it right?)-

    1>------ Build started: Project: Solo PR1, Configuration: Debug Any CPU ------

    1>

    1>  Build succeeded.

    1>           0 Warning(s).

    1>           0 Error(s).

    1>

    1>  Time elapsed 00:00:03.2503019

    1>

    ========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========

    Sorry if this has been covered but of the five previous posts suggested regarding, hello world, none seem similar to mine.

    Things I have tried ( I saw similar suggestions on the other hello world posts I read)

    1) I have tried restarting VS 2015 and the laptop.

    2) I have tried running VS 2015 as administrator.

    One of the answers I saw on the other posts (C++)  was creating an .exe (file/command?), could this be the issue here? If yes how would I do that?

    Thanks,

    EZGARA

    Friday, May 6, 2016 5:48 PM

Answers

  • How did you create your project file?  I suggest

    File > New > Project ...

    Templates > Visual C# > Windows Desktop > Console Application

    Build and run the template code as is.  It should do basically nothing.

    Then you can add the line where you have written into the existing Program.cs  (In Main, as you have written in your example)

    Console.WriteLine("Hello World!");

    Friday, May 6, 2016 6:35 PM
  • What are your build and application settings for the project?

    When creating this new project, are you sure that you created a project of type console app? And not something else like a ASP.NET app for example?

    If you really do in fact have the correct project type, then right click on the project name and go to properties... do the Assembly name and Default namespace line up with the name of your project? Is the output type set to console application? 

     
    Friday, May 6, 2016 6:46 PM

All replies

  • How did you create your project file?  I suggest

    File > New > Project ...

    Templates > Visual C# > Windows Desktop > Console Application

    Build and run the template code as is.  It should do basically nothing.

    Then you can add the line where you have written into the existing Program.cs  (In Main, as you have written in your example)

    Console.WriteLine("Hello World!");

    Friday, May 6, 2016 6:35 PM
  • What are your build and application settings for the project?

    When creating this new project, are you sure that you created a project of type console app? And not something else like a ASP.NET app for example?

    If you really do in fact have the correct project type, then right click on the project name and go to properties... do the Assembly name and Default namespace line up with the name of your project? Is the output type set to console application? 

     
    Friday, May 6, 2016 6:46 PM
  • Hi,

    Yes they do, I think it was because I didn't select Windows when I tried the first time (Just guessing) but the main reason is probably due to the issues I had when I first downloaded and installed VS 2015. I just did an update (fetched additional components under the Windows dropdown) and it ran perfectly on the first try.

    Templates > Visual C# > Windows

    But I wouldn't have picked up on it if you and Wyck didn't advise to go through the whole thing again.

    Thanks,

    EZGARA
    Friday, May 6, 2016 11:18 PM
  • Thanks a lot for this!

    Templates > Visual C# > Windows > Universal

    When I went through the steps again, I noticed that it as giving me an option to download additional dnx related extensions under Universal.

    Since one of the errors coming up mentioned dnx, I did the download. When I ran the test again it went through with no hassles.

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;

    using System.Threading.Tasks;

    namespace ConsoleApplication1

    {

        class Program

        {

            static void Main(string[] args)

            {

                Console.WriteLine("Hello again world");

            }

        }

    }

    Console appears-

    Hello again world
    Press any key to continue . . .

    Thanks,

    EZGARA

    Friday, May 6, 2016 11:41 PM
  • Glad you got it resolved.
    Friday, May 6, 2016 11:54 PM