libzmq.dll FileNotFoundException - c#

tl;dr Q. "how do we successfully deploy [unmanaged library] libzmq to load dynamically to support 'ZeroMQ CLR namespace' being used in a C# program?"
C# code with NuGet pkg ZeroMQ 4.1.0.17 (Runtime version v4.0.30319; Version 4.1.0.42169) installed. Works just fine running in the Visual Studio workspace but when deployed with the .exe in the same directory as the ZeroMQ.dll and with an amd64 subdirectory containing both libzmq.dll and libsodium.dll -- and even with copies of both those copied up into the same exec directory as program and ZeroMQ.dll -- we get:
Connect System.TypeInitializationException: The type initializer for 'ZeroMQ.lib.zmq' threw an exception. ---> System.IO.FileNotFoundException: UnmanagedLibrary[libzmq] Unable to load library "libzmq" from "C:\Windows\TEMP\libzmq.dll". Inspect Trace output for details. ---> System.IO.FileNotFoundException: The system cannot find the file specified. (Exception from HRESULT: 0x80070002)
--- End of inner exception stack trace ---
at ZeroMQ.lib.Platform.Win32.LoadUnmanagedLibrary(String libraryName)
at ZeroMQ.lib.zmq..cctor()
--- End of inner exception stack trace ---
at ZeroMQ.ZContext..ctor()
at Core.Adapter.ZeroMQ.ZeroMQMessagingService.Connect(String connection_string) in \ZeroMQMessagingService.cs:line 201
Note that is says it is looking in C:\Windows\TEMP but maybe that is only the last place in a chain.
We're getting this after upgrading to ZeroMQ 4.1.0.21 and failing to load the libzmq.dll as an "embedded resource", so we removed .21 completely and returned to .17. It had been working fine in .17 before we upgraded to .21.
Copy If Newer is checked on the amd64\libzmq.dll and libsodium.dll and, yes, this is an x64 build attempting to run on an x64 machine. The failing host is 2012 Server running .NET 4.5.

This turned out to be very simple. We are moving to a new machine still being configured and installing the C++ 2010 redistributable solved the problem for us.

Related

Published WIndows Console App fails with System.ComponentModel.Win32Exception at Microsoft.Data.SqlClient.SNINativeMethodWrapper..cctor()

I have a Windows Console application that accesses our SQL database. This app works fine from VS2019, the debug folder and the release folder. However, if I publish this app, the installed version fails with the exception shown below.
I do note the following differences between the installed location (\AppData\Local\2.0\xxx\yyy) and the \Release folder:
The \Release folder has SNI files in the \x86 and \64 directories, but the installed directory is missing this information. How do I include this in the manifest? I suspect that this is the main issue causing the exception.
The manifest file in the installed location is missing information related to Identity - not sure if this is a concern, but perhaps it is?
Application: SmartRView Configuration.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ComponentModel.Win32Exception
at Microsoft.Data.SqlClient.SNINativeMethodWrapper..cctor()
Exception Info: System.TypeInitializationException
at Microsoft.Data.SqlClient.SNINativeMethodWrapper.SNIInitialize()
at Microsoft.Data.SqlClient.SNILoadHandle..ctor()
at Microsoft.Data.SqlClient.SNILoadHandle..cctor()
Exception Info: System.TypeInitializationException
at Microsoft.Data.SqlClient.TdsParser..cctor()

Azure - Web Deployment Task Failed [System.AggregateException - WebToolsException] ERROR_COULD_NOT_CONNECT_TO_REMOTESVC

Unable to deploy to Azure App Service. What might be possibly going wrong here?
10-10-2021 11:07:06
System.AggregateException: One or more errors occurred. ---> Microsoft.WebTools.Shared.Exceptions.WebToolsException: Build failed. Check the Output window for more details.
--- End of inner exception stack trace ---
---> (Inner Exception #0) Microsoft.WebTools.Shared.Exceptions.WebToolsException: Build failed. Check the Output window for more details.<---
Microsoft.WebTools.Shared.Exceptions.WebToolsException: Build failed. Check the Output window for more details.
===================
I'm using Visual studio 2022 Preview.
I tried this solution earlier, but this didn't work in my case, this was actually due to partially deleted publish profile under the properties folder.
So completely clearing (leaving launchSettings.json intact) that and adding profile again helped me resolve this issue.

ASP NET when i try save db, i get the error Unable to load DLL 'SqlServerSpatial140.dll'

I have site on local machine and when i try callout db.SaveChanges(), i get the error: System.Reflection.TargetInvocationException: "Exception has been thrown by the target of an invocation." Inner exception: DllNotFoundException: Unable to load DLL 'SqlServerSpatial140.dll': Single module not found. (Exception from HRESULT: 0x8007007E).
But the same code work perfect on global machine. Why i can got the error?
File that wrote in exception available.
I solved my problem. I donwload this dll files (32 bit and 64 bit) - msvcp120, sqlserverspatial140 on the site: https://www.dll-files.com/
and rewrite in the folders System32(64 bit) and SysWow64(32 bit).

Why is it actually impossible to load onnxruntime.dll?

Using the tutorial from the developers at Microsoft, I followed the tutorial created at https://learn.microsoft.com/en-us/dotnet/machine-learning/tutorials/object-detection-onnx.
I made sure to install CUDA V10.1.243 and cuDNN 7.6.5 from Nvidia's site.
Yet somehow, even after copying the entire contents of C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin to my project binary's directory at machinelearning-samples\samples\csharp\end-to-end-apps\ObjectDetection-Onnx\OnnxObjectDetectionApp\bin\Debug\netcoreapp3.0, I keep running into the following error while compiling the example program MS provided: Exception thrown: 'System.DllNotFoundException' in System.Private.CoreLib.dll An exception of type 'System.DllNotFoundException' occurred in System.Private.CoreLib.dll but was not handled in user code Unable to load DLL 'onnxruntime' or one of its dependencies: The specified module could not be found. (0x8007007E).
This should make sure they are accessible from the PATH right? I'm also including their original location in NVIDIA GPU Toolkit in the system PATH as well. I am using the latest version of Visual Studio 2019 to load and compile this solution. Is there anyone out there that has been able to run this code successfully, and if so, how?

Emgu Could not found cvextern in IIS server

I'm having some issues running the Emgu on my server. It runs fine locally, but when I try to use it on the server with IIS, it doesnt work.
Here is the error:
System.TypeInitializationException: The type initializer for 'Emgu.CV.CvInvoke' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'cvextern': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
at Emgu.CV.CvInvoke.RedirectError(CvErrorCallback errorHandler, IntPtr userdata, IntPtr prevUserdata)\r\n at Emgu.CV.CvInvoke..cctor()
--- End of inner exception stack trace ---
at Emgu.CV.CvInvoke.cvCreateImageHeader(Size size, IplDepth depth, Int32 channels)
at Emgu.CV.Image`2.AllocateData(Int32 rows, Int32 cols, Int32 numberOfChannels)
at Emgu.CV.Image`2.set_Bitmap(Bitmap value)
at VerifyID.Managers.ImageTreatmentsManager.ExtractDocumentFromImage(Bitmap bitmap)
at VerifyID.VerifyWorker.ExecuteOCR(BigIdRequest request, BigIdEvent bigIdEvent)
I have the following dlls inside the x86 and x64:
concrt140.dll*
liblept172.dll*
msvcp140.dll*
vcruntime140.dll*
cvextern.dll*
libtesseract304.dll*
opencv_ffmpeg320.dll*
IIS version: 10.0
After copying the x64 dlls directly to the bin directory of the build the error changed to:
System.TypeInitializationException: The type initializer for 'Emgu.CV.CvInvoke' threw an exception. ---> System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
at Emgu.CV.CvInvoke.RedirectError(CvErrorCallback errorHandler, IntPtr userdata, IntPtr prevUserdata)
at Emgu.CV.CvInvoke..cctor()
--- End of inner exception stack trace ---
at Emgu.CV.CvInvoke.cvCreateImageHeader(Size size, IplDepth depth, Int32 channels)
at Emgu.CV.Image`2.AllocateData(Int32 rows, Int32 cols, Int32 numberOfChannels)
at Emgu.CV.Image`2.set_Bitmap(Bitmap value)
at VerifyID.Managers.ImageTreatmentsManager.ExtractDocumentFromImage(Bitmap bitmap)
at VerifyID.VerifyWorker.ExecuteOCR(BigIdRequest request, BigIdEvent bigIdEvent)
Could someone help ?
I had this same problem, the application works perfectly on the local server (IIS Express used by the Visual Studio) but not on the remote Windows server, the solution that worked for me was:
(Please test your application between each step, maybe you don't need to do them all)
In Visual Studio, open your application project properties and set the "Platform" to "Any CPU". Then publish your application to the remote server.
Move all .dll files inside the x86 folder to the bin folder, pay special attention to the cvextern.dll, it must be inside the bin folder side by side with your application dll.
Install Visual C++ Redistributable for Visual Studio on the remote server (just google it and you will find the download link. Please choose the download version according to your VS version, 2013, 2015, 2017, 2020, 2050...). Use the x86 installation even if you sever OS is x64.
Activate your app_pool for the application for running 32 bit. https://help.webcontrolcenter.com/kb/a1114/how-to-enable-32-bit-application-pool-iis-7-dedicatedvps.aspx
Go to the application \bin folder, grant the file security for the folder "x86" (which contains all the dll for emgu) as described in the following link "http://www.iis.net/learn/manage/configuring-security/application-pool-identities if your apppool being in used in defaulapppool, then you should add user "IIS AppPool\DefaultAppPool"
I really don't know why the x64 versions of those dlls are not working on the server for me. I still investigating it and as soon I find out why I will update this post.
Another solution (that is not elegant at all, but works) is to install the Visual Studio at the server, doing the same installation process that you have done for your development environment. By doing this you will have all dependencies and dlls needed (including the Visual C++) installed on the server.
Hope it helps!

Categories

Resources