0

I'm trying to write some C# .NET application to execute it on Nano Server. Here's the source code.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello hello world");
        }
    }
}

Obviously, this code is running successfully on Windows 10 system.

PS C:\Users\roza\Documents\Visual Studio 2017\Projects\ConsoleApp1\ConsoleApp1\bin\Debug> .\ConsoleApp1.exe
Hello hello world

As I understood, there're .NET Core installed on Nano Server by default, so I suppose it's possible to execute this code on Nano Server somehow.

When I copied the compiled *.exe file to Nano Server and tried to execute it there first time, I got this error:

[Nano1X]: PS C:\Users\Administrator\Documents> .\ConsoleApp1.exe
Program 'ConsoleApp1.exe' failed to run: The subsystem needed to support the image type is not present.
    + CategoryInfo          : ResourceUnavailable: (:) [], ApplicationFailedException
    + FullyQualifiedErrorId : NativeCommandFailed
[Nano1X]: PS C:\Users\Administrator\Documents>

Then I realized that Nano Server supports only x64 architecture, so I went through "Project->ConsoleApp1 Properties->Build->Platform Target: x64" and executed my app on Nano Server one more time.

[Nano1X]: PS C:\Users\Administrator\Documents> .\ConsoleApp1.exe
[Nano1X]: PS C:\Users\Administrator\Documents>

I just got nothing printed: no errors and no any result. What's the reason of it and what should I do if I really want my C# .NET application to be successfully executed by Nano Server?

Roman Zavodskikh
  • 513
  • 1
  • 6
  • 14
  • .NET Framework apps are obviously not supported on Nana if you do check Microsoft documentation. .NET Core apps are special and learn them at http://dot.net please. – Lex Li May 03 '17 at 02:57

1 Answers1

0

You won't see any output, because you are remotely starting a console application. On the nano server your application is starting, displaying "Hello hello world" and then closing. There is nothing to tie that output to your powershell window like it did when you were debugging on your Windows 10 machine.

It you want to see that the application is working, you could either make it write a text file on the file system and verify that the file gets created. Or change the app to host a web server like Kestrel, and access it remotely from your dev machine.

jpowley
  • 21
  • 3