Dapper fails with .net 4.6 - Could not load file or assembly

3

I have a WPF / MVVM Light application targeting .net 4.6 and Dapper 1.50.4 I am using Visual Studio Pro 2017 to develop the application

This application was working, but I got a new computer and moved the development of this application to the new computer. When I try to run this application on my new computer I get the following error:

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)'

What I have tried

  1. I can confirm that the dapper.dll is in the projectRoot/bin/debug directory
  2. I have run the Assembly Binding Log Viewer and I only get one error when running my application, but it is not on the dapper.dll, it is on the 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. I have uninstalled and reinstalled the NuGet package for dapper
  2. cleared out the obj folder in my project to force a rebuild
  3. the application exists in a one drive folder, so I disabled one drive thinking that the sync process might have been locking the files, but this did not fix the problem.
  4. obviously restarted Visual Studio repeatedly
  5. Updating to latest version of MVVM light - no change

Something is clearly related to moving this solution to another computer, but I am not sure where to track it down.

QUESTION

Can someone help me figure out why I am getting this error when calling dapper in my project, or help me fix it?

thanks in advance

.net
wpf
vb.net
mvvm-light
dapper
asked on Stack Overflow Feb 26, 2018 by J King • edited Feb 26, 2018 by J King

1 Answer

7

So I did not realize that there is a Strongly-Named and non named version of dapper. Truth is I did not know a lot about signed assemblies.

Solution:

  1. Remove the plain Dapper NuGet package
  2. Install the Dapper.StrongName NuGet package.

See this question(credit)

answered on Stack Overflow Feb 26, 2018 by J King

User contributions licensed under CC BY-SA 3.0