I have a C# WCF Web Service on a remote server running on IIS 8.5. One of the method of this web service tries to call a function in another custom DLL on the remote server but it returns a System.Exception specifying that it doesn't found the DLL. I logged the exception on the DLL Loader and it returns the right path to the DLL though.
The DLL is a C++ DLL used to execute a Matlab function via the runtime (installed on the server and referenced in the PATH variable as well as the DLL.
My DLL is situated in the bin folder of the project. I also tried to put it into the %windir%/System32 but same error.
By the way, the web service works great while on my Local Computer. The error only occurs while deployed
Any idea on how I can have my web service to find the DLL and execute the function?
Thanks,
Related
I have a web app on Azure. It uses .NET Core 3.1. I use two C++ DLL files as dependencies in the app. The first DLL depends or uses the second DLL. When I run the project in Visual Studio locally, there is no issue. When I deploy the app to Azure, it complains only from the second DLL, and it says "unable to load dll or one of its dependencies". As I said the first DLL use the second DLL in its codes by using " [DllImport(#"..\Folder\Second.dll")] ". What do I need to do or add in web app? Why it is working locally anf not on Azure? Any help would be appreciate.
First make sure that your .dll does not need to be registered in the registry on your local computer. Then you can copy and paste your .dll file directly into the scm website for testing. If it can be successful, then it can be supported.
In this way, we only need to add the following code to the .csproj file, and include your .dll file when publishing.
The specified files are included in the release.
If your .dll needs to be registered in the computer registry, then I can tell you clearly that azure web app is not supported because it is a sandbox environment.
But you can publish your application through azure container webapp or virtual machine.
Related Post
DLLImport does not work on Azure App Service Net. 3.1
I have created web service that uses some external dll. Evrything works fine when I run web service on IIS Express from VS IDE. Web service call dll functions without problems. But when I publish this web service to local computer IIS and call method that exposes dll function I got error:
System.BadImageFormatException: An attempt was made to load a program
with an incorrect format. (Exception from HRESULT: 0x8007000B)
According information I found on internet it might bee 64/32 bit compatibility issue. My dll is compiled like 32 bit app.
How to fix this problem?
In IIS go to the Application Pools.
Select the Application Pool of your web service then click on "Advanced Settings".
Look for the option "Enable 32-Bit Applications" and set it to true.
Then restart IIS and try again.
I had a similar problem and I solved in this way
I have a Windows Server 2008 Standard 64-bit box on which I run a test web site under IIS7.
My hosting provider has the same configuration than me yet my precious custom DLL is not honored?
Calls to my DLL (plain vanilla _CDECL Export Functions) are, well. "ignored".
No error message. Nothing. Zilch. I press the button in the middle of the page that should trigger the calls but nothing happens.
The DLL is located in C:\Windows\SysWOW64 on both machines.
That's the path used in my DllImport declaration.
The site is setup with ASP.NET v4 with Integrated Pipeline mode.
I checked for pesky dependencies and this DLL makes calls to Kernel32.dll and NTdll.dll, both of which who are sitting in C:\Windows\SysWOW64 next to my dear DLL.
No, I didn't have to register this DLL on my machine.
Any ideas would be appreciated.
I made a web application that use a DllImport to use a specific printer in my application. The printer DLL are in my System32. If I put myweb application in my web server, this DllImport will search for this Dll in my server or in the client ?
If the answer is in the client, how can I made to search this Dll in the client ?
The DLL will be searched for on the Server, not the client.
You should also know that anything printed through the .NET code will be printed on the Server side as that's where all of the .NET code executes.
I have created a C++ dll. It works fine and does the job.
I have created methods in asp.net that call the methods in C++ dll. DLL path is absolute. It works fine too.
I then published the website onto a folder and hosted the website on IIS. I get an error message
Exception Details: System.DllNotFoundException: Unable to load DLL 'FilesCreator.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
Please suggest what I need to do to get it to work.
Did you confirm that the authenticated user of the application pool which is running your app has the appropriate permissions to read and execute the DLL?
Try adding permissions for the user who is running the application pool for IIS7. For IIS6, if you are using anonymous authentication trying giving permission to the IIS anonymous user as configured in your Web Site settings.
See here for IIS6 and here for IIS7.