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

时间:2018-02-26 04:49:41

标签: .net wpf vb.net mvvm-light dapper

我有一个针对.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. 我运行了程序集绑定日志查看器,运行我的应用程序时只出现一个错误,但它不在dapper.dll上,它位于system.windows.dll:< / LI>
    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灯 - 无变化
    6. 将此解决方案移至另一台计算机显然有些问题,但我不确定在何处追踪它。

      问题

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

      提前致谢

1 个答案:

答案 0 :(得分:5)

所以我没有意识到有一个强名称和非命名的dapper版本。事实是我对签署的集会并不是很了解。

解决方案:

  1. 删除普通的Dapper NuGet包
  2. 安装Dapper.StrongName NuGet包。
  3. See this question(credit)

相关问题