Quantcast
Viewing all articles
Browse latest Browse all 193

Runtime exception referencing type from NuGet package NetMQ: 'Could not load file or assembly 'NetMQ.dll'. The system cannot find the file specified.'

Background :

  1. Consuming assembly is a .NET 6 DLL that is later used by a .NET 6 console application. This consuming assembly is loaded dynamically at runtime by the console application.
  2. All assemblies are build using Visual Studio 2022.
  3. Consuming assembly references NuGet package NetMQ version 4.0.1.13
  4. Consuming assembly builds without errors.
  5. The assemblies from the NuGet package are not visible in the project output folder after install of NuGet package or after project build. But the IDE has full IntelliSense for the types included.
  6. At runtime, at first reference to NetMQ assembly, a FileNotFound exception is thrown, reporting that the NetQM.dll can not be found.
  7. I have other NuGet packages that are used in the same way, without this issue. But have not found any help by comparing the project .nuget.dgspec.json or project.assets.json files.

What I have tried :

  1. Verified that the PackageReferance entry is part of the .csproj file. This is a .NET 6 application so that reference is simply<PackageReference Include="NetMQ" Version="4.0.1.13">
  2. Verified the TargetFramework in all my projects is net6.0. The NuGet NetMQ package includes .NETStandard, Version 2.1. See also item 6.
  3. Cleared the NuGet cache.
  4. Removed and re-installed NetMQ NuGet package.
  5. Cleaned and rebuilt the solution a number of times.
  6. Created a new test project that directly includes the consuming assemble. This is also a .NET 6 targeted project. In this case everything works as expected. At build time the dependent DLL's are copied into the output folded. And at runtime there is NO exception.
  7. Manually copied all of the depend assemblies into the original project output folder. No joy. This results in the same FileNotFound exception.
  8. Added <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> to my .csproj file. While this does result in copying all of the required assemblies to the output folder. It does not change the runtime outcome. There is still a FileNotFound exception.
  9. Enabled Fusion Log Viewer. There is nothing there that indicates that any attempt was made to resolve, load or bind the assembly in question.

Exception Message :Image may be NSFW.
Clik here to view.
enter image description here

The Question:

Does any one have any ideas that might resolve this load/bind issue?


Viewing all articles
Browse latest Browse all 193

Trending Articles