Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Microsoft.Threading.Tasks not found

Tags:

c#

.net

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.

like image 263
SamiHuutoniemi Avatar asked Sep 11 '13 09:09

SamiHuutoniemi


4 Answers

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.

like image 91
sheppe Avatar answered Nov 16 '22 00:11

sheppe


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.

like image 33
keyboardP Avatar answered Nov 16 '22 00:11

keyboardP


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.

like image 35
FallenSquirrel Avatar answered Nov 16 '22 01:11

FallenSquirrel


Just install Microsoft.Bcl.Async nuget package!

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

like image 2
Mike Keskinov Avatar answered Nov 15 '22 23:11

Mike Keskinov