C# 未找到 Microsoft.Threading.Tasks

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18737145/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 13:04:03  来源:igfitidea点击:

Microsoft.Threading.Tasks not found

c#.net

提问by SamiHuutoniemi

I have made a dll that wraps around some Google operations. With my first test drive it worked perfectly, but now in a real program, I get a weird assembly reference problem:

我制作了一个包含一些 Google 操作的 dll。在我的第一次试驾中,它运行得很好,但现在在一个真正的程序中,我遇到了一个奇怪的程序集参考问题:

FileNotFoundException was unhandled
Could not load file or assembly 'Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Det g?r inte att hitta filen.

I have heard of System.Threading.Tasks (and am "using" it), but where does Microsoft.Threading.Tasks come in? The exception occurs at the last row of the snippet below.

我听说过 System.Threading.Tasks(并且正在“使用”它),但是 Microsoft.Threading.Tasks 是从哪里来的?异常发生在下面代码段的最后一行。

Google.Apis.Admin.Directory.directory_v1.Data.Groups allGroupsResp = null;
var req = DirectoryService.Groups.List();
req.Domain = _settings.Domain;
allGroupsResp = req.Execute();

And there is no Microsoft.Threading.Tasks in the assembly list.

并且程序集列表中没有 Microsoft.Threading.Tasks。

采纳答案by keyboardP

Sounds like you're using the Google API .Net Client. I suggest using Nuget to install the assemblies as described on the linked page. However, if you download the source, the Microsoft.Threading.Taskassmeblies are included and so it seems the code your calling is trying to access those assemblies.

听起来您正在使用Google API .Net Client。我建议使用 Nuget 安装程序集,如链接页面所述。但是,如果您下载源代码,Microsoft.Threading.Task则包含程序集,因此您调用的代码似乎正在尝试访问这些程序集。

You could manually move that assembly into your directory but I'd usually opt for the Nugetmethod unless you need to be using a particular build.

您可以手动将该程序集移动到您的目录中,但Nuget除非您需要使用特定版本,否则我通常会选择该方法。

回答by Eugene Yastrebov

There could be several problems - the first one you project where you've referenced this dll is not targeted to .Net4 or you just have not installed .Net4 framework on your box.

可能有几个问题 - 您在其中引用此 dll 的第一个项目不是针对 .Net4 的,或者您只是没有在您的机器上安装 .Net4 框架。

回答by FallenSquirrel

I expect you are using the "google-api-dotnet-client". Microsoft.Threading.Tasks is a dll used by this client according to google code: https://code.google.com/p/google-api-dotnet-client/source/browse/ThirdParty/Microsoft.Threading.Tasks.dll

我希望您使用的是“google-api-dotnet-client”。Microsoft.Threading.Tasks 是这个客户端根据谷歌代码使用的一个dll:https: //code.google.com/p/google-api-dotnet-client/source/browse/ThirdParty/Microsoft.Threading.Tasks.dll

You probably just have to move this file into your bin directory.

您可能只需将此文件移动到您的 bin 目录中即可。

回答by sheppe

This is what worked for me:

这对我有用:

Open the NuGet console via the Tools menu > NuGet Package Manager > Package Manager Console

通过工具菜单 > NuGet 包管理器 > 包管理器控制台打开 NuGet 控制台

From the console type in: update-package Microsoft.Bcl.Async -reinstall

从控制台输入:update-package Microsoft.Bcl.Async -reinstall

After that, you may be prompted to re-start Visual Studio to finish uninstalling the package. Once you re-start, the package should be re-installed and everything should work.

之后,系统可能会提示您重新启动 Visual Studio 以完成包的卸载。重新启动后,应重新安装该软件包,并且一切正常。

回答by Mike Keskinov

Just install Microsoft.Bcl.Asyncnuget package!

只需安装Microsoft.Bcl.Asyncnuget包!

(if you are using Google.Apis.Oauth2.v2with UWPapp)

(如果您正在使用Google.Apis.Oauth2.v2UWP应用)