Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何引用程序集的System.Threading,_C#_Asp.net - Fatal编程技术网

C# 如何引用程序集的System.Threading,

C# 如何引用程序集的System.Threading,,c#,asp.net,C#,Asp.net,我在我的应用程序中有如下代码,起初它无法编译,它显示错误消息如下 “任务”类型存在于“System.Threading,Version=1.0.2856.102,Culture=neutral,PublicKeyToken=31bf3856ad364e35”和“mscorlib,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089”中 因此,我删除了系统。我通过Nuget安装了线程,然后新的错误消息如下: CS0012:在

我在我的应用程序中有如下代码,起初它无法编译,它显示错误消息如下

“任务”类型存在于“System.Threading,Version=1.0.2856.102,Culture=neutral,PublicKeyToken=31bf3856ad364e35”和“mscorlib,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089”中

因此,我删除了系统。我通过Nuget安装了线程,然后新的错误消息如下:

CS0012:在未引用的程序集中定义了类型“System.Threading.Tasks.Task”“1”。必须添加对程序集“System.Threading,Version=1.0.2856.102,Culture=neutral,PublicKeyToken=31bf3856ad364e35”的引用

将错误指向下面代码中的下一行

Task<HttpResponseMessage> t =  client.PostAsync("https://Mypay.com/api/", content);
这是我使用的代码:

   var client = new HttpClient();
   var values = new List<KeyValuePair<string, string>>();
   values.Add(new KeyValuePair<string, string>("task", task));
   values.Add(new KeyValuePair<string, string>("merchant", merchant_id));
   values.Add(new KeyValuePair<string, string>("ref", id));
   // include other fields
   var content = new FormUrlEncodedContent(values);


   Task<HttpResponseMessage> t =  client.PostAsync("https://Mypay.com/api/", content);
   t.Wait();
   var response = t.Result;
那么如何引用程序集或更正错误呢?

这是因为类任务是在多个引用中定义的。因此,您可以指定与其命名空间相关的名称。为此,您必须使用以下完全限定名称:

System.Threading.Tasks.Task<HttpResponseMessage> responseMEssage =  client.PostAsync("https://voguepay.com/api/", content);
由程序集名称组成 规范、命名空间规范和类型名。类型名 规范由Type.GetType、, Module.GetType、ModuleBuilder.GetType和Assembly.GetType


尝试删除对System.Runtime的引用,然后重新编译


您可以阅读有关此问题的更多信息。

在支持论坛中放置实际URL不是一个好主意,因为它可能会导致不必要的访问。您的目标framework/.NET版本是什么?目标framework是4.5I正如您所说的那样,我得到了以下错误:CS0234:命名空间“System.Threading”中不存在类型或命名空间名称“Task”是否缺少程序集引用?我更新了它,已更正,但我仍然收到前面的错误消息:CS0012:类型“System.Threading.Tasks.Task”在未引用的程序集中定义。您必须添加对程序集'System.Threading,Version=1.0.2856.102,Culture=neutral,PublicKeyToken=31bf3856ad364e35'的引用我的问题是获取NuGet Package Explorer我试图获取NuGet Package Explorer,我尝试按照您的帖子中的说明进行操作,但是资源管理器没有在System.Threading的框架程序集引用中显示System.Runtime。