首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >无法加载System.Threading.Tasks.Extensions

无法加载System.Threading.Tasks.Extensions
EN

Stack Overflow用户
提问于 2019-12-03 11:54:52
回答 9查看 52.3K关注 0票数 37

我有一个基于.net框架4.5.1的web项目。我们正试图为该项目添加PostgreSQL支持。使用Nuget,我已经在项目中安装了4.0.4npgsql。在参考资料中,我看到以下内容正在添加到项目中。

  1. Npgsql - 4.0.4.0 -运行时版本v4.0.30319
  2. System.Threading.Tasks.Extensions - 4.2.0.0 -运行时版本v4.0.30319

当我尝试运行该项目并连接并从数据库获取数据时,我会收到以下错误: FileNotFoundException:

代码语言:javascript
运行
复制
    System.TypeInitializationException
      HResult=0x80131534
      Message=The type initializer for 'com.rsol.RConfig' threw an exception.
      Source=RConfig
      StackTrace:
       at com.rsol.RConfig.getInstance() in C:\Workspaces\PS\RConfig\RConfig.cs:line 1113
       at RAdmin.Global.Application_Start(Object sender, EventArgs e) in C:\Workspaces\PS\RAdmin\Global.asax.cs:line 528

    Inner Exception 1:
    TypeInitializationException: The type initializer for 'com.rsol.Db.DbMgr' threw an exception.

    Inner Exception 2:
    FileNotFoundException: Could not load file or assembly 'System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.

    Inner Exception 3:
    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.

使用Nuget安装的System.Threading.Tasks.Extensions不会加载到项目中。当我检查System.Threading.Tasks.Extensions引用的属性时,该dll文件存在于该位置。我还尝试过使用gacutil将System.Threading.Tasks.Extensions.dll文件安装到程序集。我还是会犯同样的错误。

如果您需要更多的信息,请告诉我。

任何帮助都是非常感谢的。

EN

回答 9

Stack Overflow用户

回答已采纳

发布于 2019-12-03 12:12:17

票数 22
EN

Stack Overflow用户

发布于 2020-07-03 13:14:46

在我的例子中,我在升级到4.5.4版本后遇到了这个问题,并尝试了@user2713341答案。它不起作用,但却使我走上了正确的方向。

我的项目没有这个库的绑定,所以我添加了绑定,它工作了。

代码语言:javascript
运行
复制
<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>

而且起作用了。

请注意,即使版本为4.5.4,也应该是4.2.0.1。

票数 47
EN

Stack Overflow用户

发布于 2020-06-03 12:58:27

更新Nuget软件包不适用于我。

什么管用?在app.config中需要更改

代码语言:javascript
运行
复制
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />

代码语言:javascript
运行
复制
<bindingRedirect oldVersion="0.0.0.0-4.5.4" newVersion="4.5.4" />

对于当前版本,4.7.2应该可以工作。

微软喜欢;)

票数 10
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59156537

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档