系统相关
首页 > 系统相关> > c# – 在Linux上运行.NET Core – 什么都不写

c# – 在Linux上运行.NET Core – 什么都不写

作者:互联网

我在Visual Studio中创建了项目vNext控制台应用程序.我将这些文件复制到linux机器上.并尝试运行它们

ubuntu@ubuntu-Virtual-Machine:~/ConsoleApp2/src/ConsoleApp2$dnvm list

Active Version              Runtime Architecture OperatingSystem Alias
------ -------              ------- ------------ --------------- -----
  *    1.0.0-rc1-final      coreclr x64          linux           
       1.0.0-rc1-final      mono                 linux/osx       default

ubuntu@ubuntu-Virtual-Machine:~/ConsoleApp2/src/ConsoleApp2$dnu restore
ubuntu@ubuntu-Virtual-Machine:~/ConsoleApp2/src/ConsoleApp2$dnx run
ubuntu@ubuntu-Virtual-Machine:~/ConsoleApp2/src/ConsoleApp2$

我的应用程序没有运行.但是,如果我将dnvm切换为单声道,它可以正常工作.
我的文件内容是

Program.cs中

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

namespace ConsoleApp2
{
    public class Program
    {
        public void Main(string[] args)
        {
            Console.WriteLine("Hello world!!!!");
            Console.Read();
        }
    }
}

project.json

{
  "version": "1.0.0-*",
  "description": "ConsoleApp2 Console Application",
  "authors": [ "Anton" ],
  "tags": [ "" ],
  "projectUrl": "",
  "licenseUrl": "",

  "dependencies": {

  },

  "frameworks": {
    "dnx451": {},
    "dnxcore50": {
      "dependencies": {

        "System.Console": "4.0.0-beta-23019",
        "System.Linq": "4.0.0-beta-23019",
        "System.Threading": "4.0.10-beta-23019",
        "Microsoft.CSharp": "4.0.0-beta-23019"
      }
    }
  }
}

为什么dnx命令在切换到coreclr时什么都不写?

解决方法:

绝对肯定你错过了其中一个先决条件.它们被列为here

sudo apt-get install libunwind8 gettext libssl-dev libcurl4-openssl-dev zlib1g libicu-dev uuid-dev

标签:c,net,linux,mono,coreclr
来源: https://codeday.me/bug/20190711/1432698.html