我有一个基于 .net 框架 4.5.1 的 Web 项目。我们正在尝试为该项目添加 PostgreSQL 支持。使用 Nuget,我已经为项目安装了 4.0.4 npgsql。在参考下,我看到以下内容被添加到项目中。
当我尝试运行项目并连接并从数据库中获取数据时,出现以下错误,提示 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.
Run Code Online (Sandbox Code Playgroud)
使用 Nuget 安装的 System.Threading.Tasks.Extensions 未加载到项目中。当我检查 System.Threading.Tasks.Extensions 引用的属性时,dll 文件存在于该位置。我还尝试使用 gacutil 将 System.Threading.Tasks.Extensions.dll 文件安装到程序集。我仍然遇到同样的错误。
如果您需要任何其他信息,请告诉我。
任何帮助都非常感谢。
小智 27
就我而言,我在升级到 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>
Run Code Online (Sandbox Code Playgroud)
它奏效了。
请注意,即使版本是 4.5.4,它也应该是 4.2.0.1。
小智 15
更新 Nuget 包
https://www.nuget.org/packages/System.Threading.Tasks.Extensions/
会解决你的问题
小智 8
更新 Nuget 包对我不起作用。
什么工作?在 app.config 需要更改
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
Run Code Online (Sandbox Code Playgroud)
到
<bindingRedirect oldVersion="0.0.0.0-4.5.4" newVersion="4.5.4" />
Run Code Online (Sandbox Code Playgroud)
对于当前版本 4.7.2 应该可以工作。
微软喜欢;)
| 归档时间: |
|
| 查看次数: |
26776 次 |
| 最近记录: |