如何解决Datastax C#驱动程序.Build引发System.IO.FileLoadException
看起来我有一个绑定重定向问题,我不知道如何解决。
调用.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,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
。
此错误不是在本地发生,而是在我部署应用程序时发生。
我该如何解决?
解决方法
您可以尝试在使用DataStax驱动程序的项目中安装System.Threading.Tasks.Dataflow,Version=4.11.1.0
吗?
看起来有两个程序集被同一组项目引用,但是版本不同。我所做的就是将 <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
和 <PreserveCompilationContext>true</PreserveCompilationContext>
都添加到我的Start(主)项目的.csproj文件中。这在我的App.config中生成了一个绑定引用,该引用将程序集的所有早期版本指向所有项目中的单个版本。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。