SamiHuutoniemi
SamiHuutoniemi

Reputation: 1595

Microsoft.Threading.Tasks not found

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:

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.

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.

Upvotes: 18

Views: 27278

Answers (6)

Mihai
Mihai

Reputation: 343

I had a similar problem with Microsoft.Threading.Tasks.PDB not being found.

Found the solution here: Cannot find .cs files for debugging .NET source code

TL;DR: VS was trying to debug the .NET framework and I was missing the debug files. But I did not actually need to debug the .NET so i did: Tools -> Options -> Debugging -> General -> Enable just my Code

Upvotes: 0

Mike Keskinov
Mike Keskinov

Reputation: 11898

Just install Microsoft.Bcl.Async nuget package!

(if you are using Google.Apis.Oauth2.v2 with UWP app)

Upvotes: 3

sheppe
sheppe

Reputation: 718

This is what worked for me:

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

From the console type in: 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.

Upvotes: 39

keyboardP
keyboardP

Reputation: 69372

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.Task assmeblies are included and so it seems the code your calling is trying to access those assemblies.

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

Upvotes: 7

FallenSquirrel
FallenSquirrel

Reputation: 197

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

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

Upvotes: 3

Eugene Yastrebov
Eugene Yastrebov

Reputation: 401

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.

Upvotes: 0

Related Questions