Dapper在.NET 4.6下失败 - 无法加载文件或程序集

3

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

这个应用程序之前是可以工作的,但是我换了一台新电脑并将该应用程序开发移到了新电脑上。当我尝试在新电脑上运行此应用程序时,会出现以下错误:

System.IO.FileLoadException:“无法加载文件或程序集'Dapper,Version=1.50.4.0, Culture=neutral, PublicKeyToken=null'或其某一个依赖项。需要强名称程序集。(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. 应用程序存在于OneDrive文件夹中,因此我禁用了OneDrive,以为同步过程可能会锁定文件,但这并没有解决问题。
  4. 显然重复启动了Visual Studio
  5. 升级到最新版本的MVVM light - 没有变化

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

问题

有人能帮我找出为什么在调用我的项目中的Dapper时出现此错误,或者帮我修复它吗?

提前感谢

1个回答

10

我之前并没有意识到Dapper有强名称和非命名版本。事实是,我对签名的程序集不够了解。

解决办法:

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

参考这个问题(致谢)


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接