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!
Related
I've been trying to publish a WPF application I've been working on to a specific folder using Microsoft Clickonce. In my application I use the OpenCV wrapper EmguCV. However, when I publish the application and download and install it on a new machine, it gets thrown the following error.
Application: Photo.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.DllNotFoundException
at Emgu.CV.CvInvoke.RedirectError(CvErrorCallback, IntPtr, IntPtr)
at Emgu.CV.CvInvoke..cctor()
Exception Info: System.TypeInitializationException
at Emgu.CV.CvInvoke.cvCreateImageHeader(System.Drawing.Size, Emgu.CV.CvEnum.IplDepth, Int32)
at Emgu.CV.Image`2[[Emgu.CV.Structure.Gray, Emgu.CV, Version=4.6.0.5131, Culture=neutral, PublicKeyToken=7281126722ab4438],[System.Byte, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].AllocateData(Int32, Int32, Int32)
Whats really confusing me though is if I download my bin folder to that same machine and run the application, it works completely fine. Because of this I know the machine is not missing any runtimes, so it would have to be with Clickonce itself. I've verified that I'm targeting x64, and have also checked that all of the EmguCV dll's are being included in the Application Files section of Clickonce. I've also checked EmguCV's documentation about the issue and I've also verified that I have the correct Nuget package with the Emgu.CV.runtime.windows package.
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()
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.
I am trying to track down an error occurring on a target machine running Windows 7 64-bit for a C# WinForms application written in Visual Studio 2008. All I have to go on is the Windows Error Reporting output from the Event Viewer. I found a lot of helpful information here: http://www.codeilove.com/2012/09/debugging-using-windows-error-reporting.html.
Problem signature:
P1: myprogram.exe // filename of the executable
P2: 1.44.0.0 // assembly version for the executable in P1
P3: 560be2df // assembly timestamp for the executable in P1
P4: mscorlib // assembly where the fault occurred
P5: 2.0.0.0 // assembly version for the assembly in P4
P6: 4ca2b889 // assembly timestamp for the assembly in P4
P7: c43 // token for the method where the fault occurred
P8: 59 // IL offset into the method specified in P7
P9: System.FormatException // name of the exception that caused the fault
From the link it appears that P7, P8, and P9 are the most important, and that I should be able to find the method def for "c43" using ILDASM by looking for 06000c43. In C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll I find the following in System.Number:
.method /*06000C43*/ assembly hidebysig static
uint64 ParseUInt64(string 'value',
valuetype System.Globalization.NumberStyles/*020003B6*/ options,
class System.Globalization.NumberFormatInfo/*020003B5*/ numfmt) cil managed
Based on this information there is a System.FormatException occurring in System.Number.ParseUInt64, right? I have searched through my project in Visual Studio, and I can't find any instances where my code calls this function. Where do I go from here?
I have a top-level exception handler for Application.ThreadException that logs unhandled exceptions to a file. In this case I am getting an application crash and nothing in my log file. Is it safe to assume this Exception is happening in a thread other than my UI?
Starting with Vista SP1 you can configure Windows Error Reporting to collect local crash dumps. Just set registry settings on the target machine as described in that article and wait till your program crashes again. After that, check the directory that you've configured as DumpFolder. You should find a .dmp file in there. Open it in WinDbg or with Visual Studio and you should be able to see a full stack trace of where the exception happened.
I am having a rather strange problem, I deployed 2 .NET applications on my machine. Both run on v2.0.
Now, while one of it works smoothly, the other one doesn't even start! Moreover, it doesn't throw any error, I couldn't see any error listings in the Event Viewer.
Becoming hard to debug. On every other machine, both the exe's work perfectly fine!
Any known issues?
EDIT:
I caught an Unhandled Exception and the exception is this;
System.Runtime.InteropServices.COMException (0x80040154): Class not registered(Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
at System.Windows.Forms.UnsafeNativeMethods.CoCreateInstance(Guid& clsid, Object punkOuter, Int32 context, Guid& iid)
at System.Windows.Forms.AxHost.CreateWithoutLicense(Guid clsid)
at System.Windows.Forms.AxHost.CreateWithLicense(String license, Guid clsid)
at System.Windows.Forms.AxHost.CreateInstanceCore(Guid clsid)
at System.Windows.Forms.AxHost.CreateInstance()
at System.Windows.Forms.AxHost.GetOcxCreate()
at System.Windows.Forms.AxHost.TransitionUpTo(Int32 state)
at System.Windows.Forms.AxHost.CreateHandle()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.AxHost.EndInit()
at BrowsingFiles.Form1.InitializeComponent()
at BrowsingFiles.Form1..ctor()
at BrowsingFiles.Program.Main(String[] args)
Thanks
You are calling a COM component that is not registered on that machine.
Ideally, your deployment project would register any COM dependencies: How To Register COM Objects in Visual Studio .NET: Steps to Register a COM Module in a Visual Studio .Net Deployment Project
One more solution apart from the one given by Mitch Wheat
Copy the DLL, in the System32 file at it's proper location and then using command prompt register the dll with the system using
regsvr32 location-of-the-dll
You can go to project -> add reference to add your com component. Make sure you have the com component loaded on this system. You can go and view the references on your previous machine and see where the references are located and modify this new machine accordingly.