question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

System.Threading.Tasks.Extensions dependency error

See original GitHub issue

Hi, many thanks for the library, I’ve just installed SocketIOClient@1.0.3.12 (runtime version is v4.0.30319) via NuGet, I could build it successfully. But when I run the app, my app when crashed because of this error:

System.IO.FileNotFoundException: Could not load file or assembly 'System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.
File name: 'System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
   at System.Threading.Channels.SingleConsumerUnboundedChannel`1..ctor(Boolean runContinuationsAsynchronously)
   at System.Threading.Channels.Channel.CreateUnbounded[T](UnboundedChannelOptions options)
   at Websocket.Client.WebsocketClient..ctor(Uri url, Func`3 connectionFactory)
   at SocketIOClient.SocketIO.ConnectAsync()
   at cBot.Robots.BitQSignalExecutor.<initRemoteSignal>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()

The program try to load System.Threading.Tasks.Extensions, Version=4.2.0.0 but the installed version is System.Threading.Tasks.Extensions, Version=4.5.4, and release history has no version 4.2.0 !!

I’m using .NET 4.7.2 and add netstandard as reference.

here my code, copied from your example:

using System.Threading.Tasks.Extensions; // ==> VS IDE highlight that no Extensions in System.Threading.Tasks

   // --- here my class's function
    public async void initRemoteSignal()
    {
      const string TEST_CHANNEL = "chat_message";
      var client = new SocketIO("http://localhost:3000");
      client.ConnectTimeout = TimeSpan.FromSeconds(5);

      client.On(TEST_CHANNEL, args =>
      {
        string text = JsonConvert.DeserializeObject<string>(args.Text);
        Console.WriteLine(args.Text);
      });

      client.OnConnected += async () =>
      {
        for (int i = 0; i < 5; i++)
        {
          await client.EmitAsync(TEST_CHANNEL, i.ToString());
          await Task.Delay(1000);
        }
        await client.EmitAsync("close", "close");
      };
      client.OnClosed += Client_OnClosed;
      await client.ConnectAsync();
    }

I checked the project’s references and sawSystem.Threading.Tasks.Extensions has already been there.

I think I got library interference issue, but I’m a new to C# .net so I dont know how to resolve this issue. Any suggestion are welcome!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
doghappycommented, Apr 21, 2020

I created a clean new project and I didn’t get any errors.

csproj

<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>

App.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
    </startup>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

package.config

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Newtonsoft.Json" version="12.0.3" targetFramework="net472" />
  <package id="SocketIOClient" version="1.0.3.12" targetFramework="net472" />
  <package id="System.Collections" version="4.3.0" targetFramework="net472" />
  <package id="System.Reactive" version="4.3.2" targetFramework="net472" />
  <package id="System.Runtime.CompilerServices.Unsafe" version="4.5.2" targetFramework="net472" />
  <package id="System.Threading.Channels" version="4.7.0" targetFramework="net472" />
  <package id="System.Threading.Tasks.Extensions" version="4.5.3" targetFramework="net472" />
  <package id="System.ValueTuple" version="4.5.0" targetFramework="net472" />
  <package id="Websocket.Client" version="4.2.3" targetFramework="net472" />
</packages>
0reactions
doghappycommented, May 21, 2020

This issue has been fixed in the latest version 2.0.0. If it has not been fixed, please reopen it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to load System.Threading.Tasks.Extensions
System.Threading.Tasks.Extensions which is installed using Nuget is not getting loaded to the project. When I checked the properties of System.
Read more >
Reference mismatch to System.Threading.Tasks.Extensions
My solution is manually add System.Threading.Tasks.Extensions nuget reference with nuget version 4.5.4 in ProjectA directly.
Read more >
[Solved]-Unable to load System.Threading.Tasks.Extensions-C#
I got a similar error message - but for a different reason. In packages.config set by NUGET manager There was a ref for...
Read more >
Could not load file or assembly 'System.Threading.Tasks. ...
I had the same problem today in a multi project solution, System.Threading.Tasks.Extensions got installed by embedding the Autofac package.
Read more >
C# – Unable to load System.Threading.Tasks.Extensions
When I tried run the project and connect and get the data from the database, I am getting the following error saying FileNotFoundException:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found