Reputation: 141
When using ImageProcessor.Net on development/production server i get the exception 'ImageProcessor.Plugins.WebP.Imaging.Formats.NativeMethods' threw an exception
Using it on localhost it works fine.
I compared the solutions file-by-file but cant find any differences
Upvotes: 1
Views: 1718
Reputation: 231
I had the exact same exception when I deployed my application to Azure.
System.TypeInitializationException: The type initializer for 'ImageProcessor.Plugins.WebP.Imaging.Formats.NativeMethods' threw an exception.
---> System.IO.FileNotFoundException: Could not find file 'C:\home\site\wwwroot\x64'.
However, in my case, I found that the problem wasn't code or missing dlls related but because the application was deployed to "Run as Package".
If you use Azure DevOps to deploy to your Windows Azure App Service, it will default to adding a new application setting named WEBSITE_RUN_FROM_PACKAGE set to a value of 1.
This setting makes your application run in "read-only" mode and when you use ImageProcessor to convert an image to WebP it throws that exception.
However, you can't just delete the WEBSITE_RUN_FROM_PACKAGE application setting because it will completely break the application, you will actually need to re-deploy your application again without that setting.
In my case, I was using Azure DevOps and the solution was to select "Web Deploy" as my deployment method and re-deploy the application again.
If you have any others questions about "Run as Package" I found this article that explains it a little more.
I hope this fixes your issue as it fixed mine!
Upvotes: 0
Reputation: 10635
From the docs.
Requires msvcr120.dll from the Visual C++ Redistributable Package for Visual Studio 2013 to be installed on the server.
If you are using version 1.0.2 or lower it instead requires msvcr110.dll from the Visual C++ Redistributable Package for Visual Studio 2012 to be installed.
You're probably missing that binary.
https://imageprocessor.org/imageprocessor/plugins/webp/
Upvotes: 3