命名空间中不存在类型或命名空间名称“Http”

时间:2021-07-31 16:09:17

标签: c#

当我运行 csc program.cs 将 .cs 编译为 .exe 时,我收到此错误: program.cs(3,18):错误 CS0234:命名空间“System.Net”中不存在类型或命名空间名称“Http”(您是否缺少程序集引用?)

using System.Collections.Generic;
using System.Net.Http;
using System.Web;
using System.Net;
using System.IO;

namespace program
{
    public static class Webhook
    {
        //you've got to change this to your own discord webhook url
        private static readonly string _hookUrl = "link removed bcos mine";


        public static void sendApi()
        {
            try
            {
                HttpClient client = new HttpClient();
                Dictionary<string, string> contents = new Dictionary<string, string>
                    {
                        { "content", "this is a discord webhook" },
                        { "username", "webhook" },
                        { "avatar_url", "" }
                    };

                client.PostAsync(_hookUrl, new FormUrlEncodedContent(contents)).GetAwaiter().GetResult();
            }
            catch { }
        }
    }
}```

0 个答案:

没有答案