您的位置:首页 > 理论基础 > 计算机网络

Mono fix compiled issue "Are you missing `System.Net.Http' assembly reference?"

2016-04-21 23:49 423 查看
写了个例子程序

using System;
using System.Net.Http;
using System.Threading.Tasks;
namespace Chapter1.Threads
{
public static class Program
{
public static void Main()
{
string result = DownloadContent().Result;
Console.WriteLine(result);
}
public static async Task<string> DownloadContent()
{
using(HttpClient client = new HttpClient())
{
string result = await client.GetStringAsync("http://www.microsoft.com");
return result;
}
}
}
}

但是用mcs 编译时,报错 

async1.cs(2,18): error CS0234: The type or namespace name `Http' does not exist in the namespace `System.Net'. Are you missing `System.Net.Http' assembly reference?

解决方法:用/reference 加上依赖的DLL

mcs /reference:System.Net.Http async1.cs
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  mono .net mac compile failed