I have a web application which is hosted in Azure. When I run the app and authenticate the user, I am getting the error "One of the dependent DLL not found".
Background:
In the web application, I am using fingerprint scanner functionality to capture a fingerprint image. To capture fingerprint image during user registration, I am using a javascript library and it works fine. I am storing the fingerprint in storage. When a user logs in into the website, I need to perform authentication and again I capture fingerprint from the user and compare it with one associated with the user. For comparing two fingerprint images on server-side, my C# code calls fingerprint scanner SDK which in turn calls dependent DLL's (from System32) which I guess comes with fingerprint scanner SDK. When I run the site locally, it works fine (as I have fingerprint SDK installed on the local machine). But when I deploy the application on Azure and this code execute, I am getting the error "One of the dependent DLL not found". I understand run time is looking for one of the dependent DLL from the system32 folder which is not there in the Azure environment.
I tried copying fingerprint scanner DLL's to Azure web apps bin folder but it not working. I am getting the error An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B).
Image - which shows DLL added to root folder
I also tried to include system 32 DLLto .net core class library project but it gives error The reference is invalid or unsupported
Image - Error while adding system32 DLL to .net core project
Is there any way to install third party software on the Azure web app?
You can't directly install 3rd party DLLs in App Service. One way around that is to deploy your app in a Windows container that App Service will pull and run. Another way is to use a virtual machine instead of App Service, this way you have full control of the machine and you can install whatever you want.
One possibility is to use Windows Containers in App Service.
Here you can follow the quickstart to run a Windows Container in App Service:
https://learn.microsoft.com/en-us/azure/app-service/app-service-web-get-started-windows-container
Following will be the steps to resolve the issue
• Make sure correct native library (Third party DLL’s) copied to a wwwroot folder on the server (either 64bit or 32 bit)
• Check azure web service configuration platform (If third party dll is 64 bit then change to 64 bit)
• From the visual studio, while publish an application using web deploy to make sure deployment mode is self-contained and Target runtime win-x64
Additional things that need to take care
• If the project is in the .net core then we can not add direct third part dll reference, we need to add an existing item and in property of dll make sure it copies always
• Change Platform target to 64 or 32 bit as per project requirement
Above steps works for me
Related
In our ASP.NET Core web api, we are attempting to load unmanaged C++ code from a DLL that we included in our published folder.
This fails upon calling the endpoint that loads the DLL. The exception is as follows:
DllNotFoundException: Unable to load DLL 'libespeak-ng' or one of its dependencies: The specified module could not be found. (Exception from HRESULT: 0x8007007E)
It should be noted that this DLL loads and functions fine when the app is run through Visual Studio. Running the app in Kestrel with the dotnet command also works properly, on the same server. It is only inside of IIS that the app fails to load this DLL.
We have made sure the IIS user (as well as the default app pool) has permission to read and execute the DLL. We've tried placing the DLL in the app bin folder, in System32, in SysWOW64, and in the various inetsrv directories. None of this has resolved the issue.
Looking at ProcMon, it seems like IIS does not even attempt to load the DLL. Dependency Walker doesn't reveal any missing dependencies that aren't also missing when running it with Kestrel on any machine.
After many hours of struggling, and attempting the solutions commented by other users, we finally figured out the issue.
The DLL was trying to access some Windows APIs that did not exist in Windows Server 2012 R2, apparently. Once we updated the server to the latest windows server version, everything worked without issue.
I have ZK Teco Bio-metrics Attendance device. I need to integrate this device with my Asp.net project, so my team can remotely access the machine to check their attendance records. I have downloaded Official SDK and add references in my project and have gone through with the registry process to make device connection but I can't make the connection and getting this error:
"Retrieving the COM class factory for component with CLSID {00853A19-BD51-419B-9269-2DABE57EB61F} failed due to the following error: 800700c1 is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)."
However, I have successfully connected the device with my C# Windows Form project (Desktop Application) and can use all functionalities of the same SDK.
What should I do to connect the device with my Asp.net project?
There are two possible reason for this error.
First reason
The ZK Techo SDK dlls are not registered under your windows 32 bit directory
Solution:
TO register the ZK dll under windows 32 bit directory
Step 1
Download the latest version of ZK SDK from the ZKTeco website
Step 2
Extract the downloaded folder and open it.
It contains “SDK-Ver*\32bit\” folder open it and copy all the file under 32 bit folder
*is the available version number
Step 3
Paste all the copied files under windows 32 bit directory folder
The most common path of windows 32 directory folder is
“C:\Windows\System32\”
Step 4 (Register ZK 32 bit SDK)
The files you Just copied and pasted into windows 32 bit directory folder contains a file name “Register_SDK_x86.bat” run it as Administrator and wait until the ZK SDK dll are registered it usually take 2 -3 minutes.
Second Reason
Change the target platform of your Web Application from Any CPU to x86.
Right click on your project name in visual studio solution explorer go to
properties -> Build -> under general you can find Platform target change it to Any CPU to x86.
Build your web application and publish it.
Hopefully your problem shall be solved.
I am using Ghostscript.NET in order to convert a PDF page into a jpg. This all works fine when I run it locally, but when I publish it to an Azure website then I get the error:
"This managed library is running under 32-bit process and requires 32-bit Ghostscript native library installation on this machine! To download proper Ghostscript native library please visit: http://www.ghostscript.com/download/gsdnld.html"
Obviously I can't just install Ghostscript on the server that the Azure Website is running on, I don't have access to do that. Is there any way that I can include a Ghostscript library in the publishing profile, and have Ghostscript.NET read from that?
Alternatively, is there any package that would allow me to convert a PDF page to a jpg thumbnail on an ASP.NET server without using Ghostscript at all? I have also tried GhostScriptSharp and had no luck with that either.
You could try to install native ghostscript library to your local machine and get gsdll32.dll (or gsdll64.dll if you are running in x64 bit environment) which you can deploy to your server along with the other dlls.
Take a look at this example how to tell Ghostscript.NET where to search for the native ghostscript library dll: https://github.com/jhabjan/Ghostscript.NET/blob/master/Ghostscript.NET.Samples/Samples/CustomGsdllLocationSample.cs
You have a few options.
Host your website as an Azure Cloud Service Web Role. This allows you to react to the server being created and you can run installation programs (if you can automate them) to prep the machine.
Split this functionality out into an Azure Cloud Service Worker Role (where you can do the same machine prep) and have it respond to an Azure Queue item. This way your website remains pretty much as is.
Be careful though, Cloud Services can get expensive if they are just sitting there doing nothing because its still running on a VM. You can have your Cloud Service scale based on the queue having items or not.
I'm getting this error whenever I try to debug the Azure project from Visual Studio. I checked on my original site project file the Platform Target and project's and every dependence as well are using "Any CPU". Not really sure what to do from here.
Could not load file or assembly 'Pechkin' or one of its dependencies.
Are you running 32 bit allowed? Lots of docs out there talk about this being a limitation.
mark as the answer please if that is the problem. There are solutions as well. apparently a guy did a fork called tuesPechkin with 64 bit versions.
It's not possible to get wkhtmltopdf working on Azure. See this thread and this Gitgub issue.
I am assuming you mean running wkhtmltopdf on Windows Azure Websites.
wkhtmltopdf uses Window's GDI APIs which currently don't work on Azure
Websites.
A solution could be to create a Windows service (or for example a web api endpoint), which runs the Tuespechkin converter. Then create a VM in Azure and install the Windows service/end point there.
I am working on a Web Application on a Windows 8 64 bit machine using multiple existing libraries. I want to use two C# DLLs referencing one native DLL. Both C# DLLs are compiled for 64bit usage and tested in test applications.
My web application references both C# DLLs and is supposed to run on IIS 8.
I added the two C# DLLs as references to the project and the native DLL manually to the bin folder of the web app. Whenever I build and run the solution I get the exception shown in the title.
I know that this is a sign for a problem regarding 32 bit and 64 bit code running in one process. Therefore I tried all different build configurations but the result never changed.
I created a console application doing exactly what I'm trying in the web app and it worked flawlessly.
The Web application with the exact same settings however throws the exception, this is what is really confusing to me.
What I tried so far:
Change application pool setting to "enable 32-bit applications"
Build all DLLs with Any CPU, 64Bit or x86 target
Check the corflags of all DLLs
I can provide an export of the project to everybody willing to help me get this configuration running!
I really appreciate every bit of help!
I presume you tried with setting Target Platform (Build option in project properties)?
Also, take a look at this article:
http://www.codeproject.com/Articles/383138/BadImageFormatException-x86-i-x64
I got the same issue on my application. It was fixed after I perform the following:
* Granting permission for the "Anonymous" user in my web site folder.
* Changing the application pool from ".NET v4.5 Classic" to ".NET v4.5".
All I can offer is some help in determining what isn't loading. If it's a dev server it might be worthwhile to install the appropriate sdk to use the Fusion Log Viewer. If that isn't an option you can turn on assembly binding logging from the registry as follows:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion]
"LogFailures"=dword:00000001
"LogPath"="c:\\bindFailureLogs\\"
just be sure to turn it off when you're done, there is a performance penalty using the assembly bind logging. Make sure the folder exists before you enter the registry key and recycle the application pool of the application for the logging to start. This will provide you a detailed list of what dll (or dependency since it's not always readily apparent if it's a dependancy or the dll listed in the error message) didn't load and where it tried to load it from.
Your partitioning of the applications fixing the problem suggests that there are multiple dependencies on the assembly targeting different versions and since only a single version of an assembly can be loaded into an app domain some dependency isn't being satisfied. For managed assemblies you could use an assembly binding redirect, but I don't know what the unmanaged equivalent of that would be if it even exists.