带有DnSpy的问题类C#System.Net.Http
我有一个小问题,我想在使用DnSpy的应用程序中添加一个新的类C 我的课程是Webhook.cs for Discord 当我添加它并尝试编译它时,会显示一个错误: 命名空间“System.Net”中不存在类型或命名空间名称“Http”(是否缺少程序集引用?) 我不知道如何使用DnSpy添加System.Net.Http,而且我没有添加它的源代码 如果你想知道,我的课程是:带有DnSpy的问题类C#System.Net.Http,c#,C#,我有一个小问题,我想在使用DnSpy的应用程序中添加一个新的类C 我的课程是Webhook.cs for Discord 当我添加它并尝试编译它时,会显示一个错误: 命名空间“System.Net”中不存在类型或命名空间名称“Http”(是否缺少程序集引用?) 我不知道如何使用DnSpy添加System.Net.Http,而且我没有添加它的源代码 如果你想知道,我的课程是: using System.IO; using System.Net; using System.Net.Http; /*
using System.IO;
using System.Net;
using System.Net.Http;
/*
* Created this for making it easier to use
*/
namespace Misaki
{
class Webhook
{
private HttpClient Client;
private string Url; //Url of the webhook
public string Name { get; set; }
public string ProfilePictureUrl { get; set; } //make sure that this is "" and not null if you don't wanna have it use a profile picture
public Webhook(string webhookUrl)
{
Client = new HttpClient();
Url = webhookUrl;
}
//method for sending the message (if file is null (which it is by default) no file will be included)
public bool SendMessage(string content, string file = null)
{
MultipartFormDataContent data = new MultipartFormDataContent();
data.Add(new StringContent(Name), "username");
data.Add(new StringContent(ProfilePictureUrl), "avatar_url");
data.Add(new StringContent(content), "content");
if (file != null)
{
//throws exception if file doesn't exist
if (!File.Exists(file))
throw new FileNotFoundException();
byte[] bytes = File.ReadAllBytes(file);
data.Add(new ByteArrayContent(bytes), "file", "file.txt");
}
var resp = Client.PostAsync(Url, data).Result;
return resp.StatusCode == HttpStatusCode.NoContent;
}
}
}
谢谢你的帮助 右键单击VS项目中解决方案资源管理器中的References文件夹。如果单击“添加”,则应该能够看到提示。查看是否存在
System.Net
或System.Net.Http
以及是否勾选了它们。可能是版本问题。您的项目引用的是哪个版本的.NET,您安装的是哪个版本的System.NET?