gpt4 book ai didi

.net - Dapper 使用 .net 4.6 失败 - 无法加载文件或程序集

转载 作者:行者123 更新时间:2023-12-01 05:09:30 25 4
gpt4 key购买 nike

我有一个针对 .net 4.6 和 Dapper 1.50.4 的 WPF/MVVM Light 应用程序我正在使用 Visual Studio Pro 2017 开发应用程序

此应用程序正在运行,但我得到了一台新计算机并将此应用程序的开发转移到新计算机上。当我尝试在我的新计算机上运行此应用程序时,我收到以下错误:

System.IO.FileLoadException: 'Could not load file or assembly 'Dapper, Version=1.50.4.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)'

我尝试过的

  1. 我可以确认 dapper.dll 在 projectRoot/bin/debug 目录中
  2. 我已经运行了 Assembly Binding Log Viewer,但在运行我的应用程序时只收到一个错误,但它不在 dapper.dll 上,它在 system.windows.dll 上:
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.

Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable C:\Users\jorda\...\bin\Debug\FTC_Application.exe
--- A detailed error log follows.

=== Pre-bind state information ===
LOG: DisplayName = System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
(Fully-specified)
LOG: Appbase = file:///C:/Users/jorda/.../bin/Debug/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = FTC_Application.exe
Calling assembly : GalaSoft.MvvmLight, Version=5.3.0.19026, Culture=neutral, PublicKeyToken=e7570ab207bcb616.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\jorda\...\bin\Debug\FTC_Application.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Users/jorda/.../bin/Debug/System.Windows.DLL.
LOG: Attempting download of new URL file:///C:/Users/jorda/.../bin/Debug/System.Windows/System.Windows.DLL.
LOG: Attempting download of new URL file:///C:/Users/jorda/.../bin/Debug/System.Windows.EXE.
LOG: Attempting download of new URL file:///C:/Users/jorda/.../bin/Debug/System.Windows/System.Windows.EXE.
LOG: All probing URLs attempted and failed.
  1. 我已经卸载并重新安装了适用于 dapper 的 NuGet 包
  2. 清除我项目中的 obj 文件夹以强制重建
  3. 该应用程序存在于一个驱动器文件夹中,因此我禁用了一个驱动器,认为同步过程可能已锁定文件,但这并没有解决问题。
  4. 显然反复重启了 Visual Studio
  5. 更新到最新版本的 MVVM light - 没有变化

显然与将此解决方案移动到另一台计算机有关,但我不确定在哪里可以找到它。

问题

有人可以帮我弄清楚为什么在我的项目中调用 dapper 时出现此错误,或者帮我修复它吗?

提前致谢

最佳答案

所以我没有意识到 dapper 有强命名和非命名版本。事实上,我对已签名的程序集知之甚少。

解决方案:

  1. 删除普通的 Dapper NuGet 包
  2. 安装 Dapper.StrongName NuGet 包。

See this question(credit)

关于.net - Dapper 使用 .net 4.6 失败 - 无法加载文件或程序集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48981625/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com