Mono fix compiled issue "Are you missing `System.Net.Http' assembly reference?"
2016-04-21 23:49
417 查看
写了个例子程序
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
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
相关文章推荐
- 如何在 Linux/Windows/MacOS 上使用 .NET 进行开发
- 什么是Mac OS X?跟Linux有什么区别
- mac下安装mysql(转载)
- mysql 修改编码 Linux/Mac/Unix/通用(杜绝修改后无法启动的情况!)
- 如何在 Linux 中安装微软的 .NET Core SDK
- Linux vs Mac:Linux 比 Mac 好的 7 个原因
- 苹果mac OS X上安装metasploit
- C#.NET获取拨号连接的宽带连接方法
- C#.Net ArrayList的使用方法
- Validation of viewstate MAC failed.的解决方法
- Mac平台中编译安装Lua运行环境及Hello Lua实例
- 在Mac OS中安装Lua的教程
- PowerShell中使用.NET将程序集加入全局程序集缓存
- .net(c#)中的new关键字详细介绍
- 由vbs sort引发.NET Framework之间的关系说明
- vbs Windows系统改变或修改网卡的MAC地址的脚本与软件第1/2页
- MAC官方菜单纯CSS实现灰色会换色
- C#难点逐个击破(6):C#数据类型与.net framework数据类型
- .NET中的async和await关键字使用及Task异步调用实例
- mac系统OS X10.10版本安装最新5.7.9mysql的方法