我有一个基于.net框架4.5.1的web项目。我们正试图为该项目添加PostgreSQL支持。使用Nuget,我已经在项目中安装了4.0.4npgsql。在参考资料中,我看到以下内容正在添加到项目中。
当我尝试运行该项目并连接并从数据库获取数据时,我会收到以下错误: FileNotFoundException:
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文件安装到程序集。我还是会犯同样的错误。
如果您需要更多的信息,请告诉我。
任何帮助都是非常感谢的。
发布于 2019-12-03 12:12:17
发布于 2020-07-03 13:14:46
在我的例子中,我在升级到4.5.4版本后遇到了这个问题,并尝试了@user2713341答案。它不起作用,但却使我走上了正确的方向。
我的项目没有这个库的绑定,所以我添加了绑定,它工作了。
<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。
发布于 2020-06-03 12:58:27
更新Nuget软件包不适用于我。
什么管用?在app.config中需要更改
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
至
<bindingRedirect oldVersion="0.0.0.0-4.5.4" newVersion="4.5.4" />
对于当前版本,4.7.2应该可以工作。
微软喜欢;)
https://stackoverflow.com/questions/59156537
复制相似问题