【问题标题】:Datastax C# Driver .Build() Throws System.IO.FileLoadExceptionDatastax C# 驱动程序 .Build() 引发 System.IO.FileLoadException
【发布时间】:2021-01-24 22:32:12
【问题描述】:

看起来我遇到了一个不知道如何解决的绑定重定向问题。

.Build() 被调用时,我得到以下异常:

[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=4.6.0.0, 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=4.6.0.0, 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

我在这个解决方案中有另一个项目引用System.Threading.Tasks.Dataflow, Version=4.11.1.0

此错误不会在本地发生,而是在我部署应用程序时发生。

我该如何解决这个问题?

【问题讨论】:

    标签: c# cassandra datastax csproj assembly-binding-redirect


    【解决方案1】:

    您可以尝试在使用 DataStax 驱动程序的项目中安装System.Threading.Tasks.Dataflow, Version=4.11.1.0 吗?

    【讨论】:

      【解决方案2】:

      看起来有两个程序集被同一组项目引用,但版本不同。我所做的是将 &lt;AutoGenerateBindingRedirects&gt;true&lt;/AutoGenerateBindingRedirects&gt; &lt;PreserveCompilationContext&gt;true&lt;/PreserveCompilationContext&gt; 添加到我的启动(主)项目的.csproj 文件中。这会在我的 App.config 中生成一个绑定引用,它将所有早期版本的程序集指向所有项目中的单个版本。

      【讨论】:

        猜你喜欢
        • 2014-03-16
        • 2019-12-27
        • 2017-08-04
        • 2014-03-27
        • 2016-02-27
        • 2017-01-20
        • 2017-01-26
        • 2016-09-06
        • 2017-01-31
        相关资源
        最近更新 更多