Datastax C# Driver .Build() Throws System.IO.FileLoadException


looks like I have a binding redirects issue that I don't know how to solve.

When .Build() is called, I get the following exception:

[2020-10-09 14:09:28.806] [                              :001] [ERROR] [DatabaseClient                ] Failed to connect to Cassandra Database...
System.IO.FileLoadException: Could not load file or assembly 'System.Threading.Tasks.Dataflow, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'System.Threading.Tasks.Dataflow, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
   at Cassandra.ProtocolEvents.ProtocolEventDebouncer..ctor(ITimerFactory timerFactory, TimeSpan delay, TimeSpan maxDelay)
   at Cassandra.Cluster..ctor(IEnumerable`1 contactPoints, Configuration configuration)
   at Cassandra.Cluster.BuildFrom(IInitializer initializer, IReadOnlyList`1 nonIpEndPointContactPoints, Configuration config)
   at OpportunityRecorder.DatabaseClient.<ConnectToCassandraAsync>d__12.MoveNext() in C:\Gitlab-Runner\builds\4Gddire9\0\dev\V\OpportunityRecorder\OpportunityRecorder\DatabaseClient.cs:line 46

I have another project in this solution that references System.Threading.Tasks.Dataflow, Version=

This error doesn't happen locally, but happens when I deploy my application.

How can I fix this?

asked on Stack Overflow Oct 9, 2020 by Tee Zad Awk

2 Answers


Can you try installing System.Threading.Tasks.Dataflow, Version= in the project that uses the DataStax driver?

answered on Stack Overflow Oct 12, 2020 by João Reis

Looks like there were two assemblies being references by the same set of projects, but with different versions. What I did was add both <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> and <PreserveCompilationContext>true</PreserveCompilationContext> to my .csproj file for my StartUp (main) project. This generated a binding reference in my App.config that would point all earlier versions of the assembly to a single version amongst all projects.

enter image description here

answered on Stack Overflow Oct 12, 2020 by Tee Zad Awk

User contributions licensed under CC BY-SA 3.0