nopCommerce throws exception after upgrade from 4.00 to 4.10 "Could not load file or assembly StackExchange.Redis.StrongName"

1 year ago
After merging the 4.10 master branch into my local repo, the solution builds without errors but when I try to run it, it now throws an exception

Application startup exception: System.Exception: Plugin 'ECB exchange rate provider'. Could not load file or assembly 'StackExchange.Redis.StrongName, Version=1.2.6.0, Culture=neutral, PublicKeyToken=c219ff1ca8c2ce46'.
Could not load file or assembly 'StackExchange.Redis.StrongName, Version=1.2.6.0, Culture=neutral, PublicKeyToken=c219ff1ca8c2ce46'.
---> System.Exception: Plugin 'ECB exchange rate provider'. Could not load file or assembly 'StackExchange.Redis.StrongName, Version=1.2.6.0, Culture=neutral, PublicKeyToken=c219ff1ca8c2ce46'. ---> System.IO.FileLoadException: Could not load file or assembly 'StackExchange.Redis.StrongName, Version=1.2.6.0, Culture=neutral, PublicKeyToken=c219ff1ca8c2ce46'.
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, String ilPath, String niPath, ObjectHandleOnStack retAssembly)
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
   at System.Reflection.Assembly.LoadFrom(String assemblyFile)
   at Nop.Core.Plugins.PluginManager.RegisterPluginDefinition(NopConfig config, ApplicationPartManager applicationPartManager, String plug) in C:\Users\Lena\source\repos\nopCommerce\src\Libraries\Nop.Core\Plugins\PluginManager.cs:line 256
   at Nop.Core.Plugins.PluginManager.PerformFileDeploy(String plug, ApplicationPartManager applicationPartManager, NopConfig config, String shadowCopyPath) in C:\Users\Lena\source\repos\nopCommerce\src\Libraries\Nop.Core\Plugins\PluginManager.cs:line 220
   at Nop.Core.Plugins.PluginManager.Initialize(ApplicationPartManager applicationPartManager, NopConfig config) in C:\Users\Lena\source\repos\nopCommerce\src\Libraries\Nop.Core\Plugins\PluginManager.cs:line 485
   --- End of inner exception stack trace ---

The StackExchange.Redis.StrongName.dll file does exist: "C:\...\source\repos\nopCommerce\src\Presentation\Nop.Web\Plugins\ExchangeRate.EcbExchange\StackExchange.Redis.StrongName.dll"

The version is 1.2.6, dated 8/1/2017, and I have granted Modify access to Everyone, so NTFS permissions should not be an issue.

Nop.Core dependencies in VS2017 indicates Redlock.net.StrongName 2.0.0 epends on StackExchange.Redis.StrongName 1.2.4, which should be sufficient according to the NuGet gallery.

Disabling shadow copy of plugins did not make any difference.

I have installed all available updates to NuGet packages.

How can I troubleshoot and resolve this issue?

Thank you!
1 year ago
I am having this problem as well
1 year ago
When I had this problem, I suspect the root cause was that I had not cleaned the solution before merging version 4.10 from Github into my local repo and working directory. After the merge, Clean Solution no longer removed the net461 folders, only the new netcoreapp2.1 ones.

The Nop.Web\bin\Debug\net461\Nop.Web.deps.json file contained a reference to
"Microsoft.AspNetCore.DataProtection.Redis/0.3.0": {
  "dependencies": {
    "Microsoft.AspNetCore.DataProtection": "2.0.0",
    "StackExchange.Redis.StrongName": "1.2.6"
  },
  "compile": {
    "lib/netstandard2.0/Microsoft.AspNetCore.DataProtection.Redis.dll": {}
  }
}

Of course that didn't show up anywhere in Visual Studio, but I finally found the reference by scanning the entire working directory for 1.2.6 with Agent Ransack, and manually removed all net461 folders (definitely make a backup copy of the working directory first!), as well as copies of the StackExchange.Redis.StrongName.dll in the Nop.Web\Plugins\bin and Nop.Web\Plugins\EcbExchangeRate folders, followed by uninstalling and reinstalling the Redlock.net.StrongName NuGet package. That resolved the issue in my case.


(The "normal" solution would be to either try to install the missing NuGet package version, or find where the missing version is referenced and see if it might work to reference the version that is actually installed instead.)