imazen / imageflow-dotnet

The official .NET API for Imageflow, the Rust image processing and optimization engine for web servers
GNU Affero General Public License v3.0
143 stars 25 forks source link

Imageflow Module not found when deployed to a production server #20

Closed thecaptncode closed 3 years ago

thecaptncode commented 3 years ago

We are starting to use Imageflow.net within an ASP.net application. Imageflow is set up and working fine with our development and test servers, but when deployed to our production servers, which are very similarly configured VMs, we started receiving the following error.

Looking for "imageflow.dll" Subdir="x64", IsUnix=False, IsDotNetCore=False Before searching: Unable to load DLL 'imageflow': The specified module could not be found. (Exception from HRESULT: 0x8007007E) File not found: C:\Websites\demo\x64\imageflow.dll
File not found: C:\Websites\demo\imageflow.dll
File not found: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\demo\07ba4e9d\500187f\assembly\dl3\ab715b07\00118335_6882d601\x64\imageflow.dll
File not found: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\demo\07ba4e9d\500187f\assembly\dl3\ab715b07\00118335_6882d601\imageflow.dll
File not found: C:\Websites\demo\runtimes\win-x64\native\x64\imageflow.dll
File not found: C:\Websites\demo\runtimes\win-x64\native\imageflow.dll
File not found: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\demo\07ba4e9d\500187f\assembly\dl3\ab715b07\00118335_6882d601\runtimes\win-x64\native\x64\imageflow.dll
File not found: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\demo\07ba4e9d\500187f\assembly\dl3\ab715b07\00118335_6882d601\runtimes\win-x64\native\imageflow.dll
   at Imageflow.Bindings.NativeMethods.imageflow_context_create(UInt32 imageflow_abi_ver_major, UInt32 imageflow_abi_ver_minor)
   at Imageflow.Bindings.NativeLibraryLoader.FixDllNotFoundException[T](String basename, Func`1 invokingOperation, IEnumerable`1 customSearchDirectories)

Stack Trace:    at Imageflow.Bindings.LoadLogger.RaiseException()
   at Imageflow.Bindings.NativeLibraryLoader.FixDllNotFoundException[T](String basename, Func`1 invokingOperation, IEnumerable`1 customSearchDirectories)
   at Imageflow.Bindings.JobContextHandle..ctor()
   at Imageflow.Bindings.JobContext..ctor()
   at Imageflow.Fluent.ImageJob.<GetImageInfo>d__50.MoveNext()

C:\Websites\demo is the application root and the 64 bit runtime is in the C:\Websites\demo\bin folder. I have verified that the Application Pools are 64 bit only on all servers.

lilith commented 3 years ago

Have you set the solution to build as Any CPU or as x64? The latter may be required.

On Sun, Sep 20, 2020, 1:36 PM thecaptncode notifications@github.com wrote:

We are starting to use Imageflow.net within an ASP.net application. Imageflow is set up and working fine with our development and test servers, but when deployed to our production servers, which are very similarly configured VMs, we started receiving the following error.

Looking for "imageflow.dll" Subdir="x64", IsUnix=False, IsDotNetCore=False Before searching: Unable to load DLL 'imageflow': The specified module could not be found. (Exception from HRESULT: 0x8007007E) File not found: C:\Websites\demo\x64\imageflow.dll File not found: C:\Websites\demo\imageflow.dll File not found: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\demo\07ba4e9d\500187f\assembly\dl3\ab715b07\00118335_6882d601\x64\imageflow.dll File not found: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\demo\07ba4e9d\500187f\assembly\dl3\ab715b07\00118335_6882d601\imageflow.dll File not found: C:\Websites\demo\runtimes\win-x64\native\x64\imageflow.dll File not found: C:\Websites\demo\runtimes\win-x64\native\imageflow.dll File not found: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\demo\07ba4e9d\500187f\assembly\dl3\ab715b07\00118335_6882d601\runtimes\win-x64\native\x64\imageflow.dll File not found: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\demo\07ba4e9d\500187f\assembly\dl3\ab715b07\00118335_6882d601\runtimes\win-x64\native\imageflow.dll at Imageflow.Bindings.NativeMethods.imageflow_context_create(UInt32 imageflow_abi_ver_major, UInt32 imageflow_abi_ver_minor) at Imageflow.Bindings.NativeLibraryLoader.FixDllNotFoundException[T](String basename, Func1 invokingOperation, IEnumerable1 customSearchDirectories)

Stack Trace: at Imageflow.Bindings.LoadLogger.RaiseException() at Imageflow.Bindings.NativeLibraryLoader.FixDllNotFoundException[T](String basename, Func1 invokingOperation, IEnumerable1 customSearchDirectories) at Imageflow.Bindings.JobContextHandle..ctor() at Imageflow.Bindings.JobContext..ctor() at Imageflow.Fluent.ImageJob.d__50.MoveNext()

C:\Websites\demo is the application root and the 64 bit runtime is in the C:\Websites\demo\bin folder. I have verified that the Application Pools are 64 bit only on all servers.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/imazen/imageflow-dotnet/issues/20, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA2LH4LRCSGB6PBTHEO3ODSGZKVDANCNFSM4RTZ42HQ .

thecaptncode commented 3 years ago

Reading your reply made me realize I misspoke an important detail. This is a Web Site Project and not a Web Application. My understanding is they are always targeted to "Any CPU" but you control 64 vs 32 bit by the application pool. The application pool on the Dev and Test servers as well as the production servers are set to not allow 32 bit.

Also, I am running 0.7.2 of imageflow.net and ImageFlow.NativeRuntime.win-x86_64 1.4.10-rc50

lilith commented 3 years ago

Can you confirm the exact path of imageflow.dll on the production server?

On Sun, Sep 20, 2020, 6:43 PM thecaptncode notifications@github.com wrote:

Reading your reply made me realize I misspoke an important detail. This is a Web Site Project and not a Web Application. My understanding is they are always targeted to "Any CPU" put you control 64 vs 32 bit by the application pool. The application pool on the Dev and Test servers as well as the production servers are set to not allow 32 bit.

Also, I am running 0.7.2 of imageflow.net and ImageFlow.NativeRuntime.win-x86_64 1.4.10-rc50

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/imazen/imageflow-dotnet/issues/20#issuecomment-695859206, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA2LH3JMOLX6LTVAC2OKQTSG2OSNANCNFSM4RTZ42HQ .

thecaptncode commented 3 years ago

The path is C:\Websites\demo\bin\imageflow.dll and the application root is C:\Websites\demo\

lilith commented 3 years ago

Okay. I think I've added support for Web Site projects in https://github.com/imazen/imageflow-dotnet/releases/tag/v0.7.4

Can you report back and let me know how it goes? I tried setting up a web site project but the Imageflow.NativeRuntime.* packages aren't even able to copy imageflow.dll into the /bin folder. Did you copy it manually?

thecaptncode commented 3 years ago

Yes, I had to copy the imageflow.dll manually. It did not copy automatically.

I tried the updated DLL and it did not work. Here is the error I received.

Looking for "imageflow.dll" RID="win-x64", IsUnix=False, IsDotNetCore=False RelativeSearchPath="C:\Websites\demo\bin"
Before searching: Unable to load DLL 'imageflow': The specified module could not be found. (Exception from HRESULT: 0x8007007E) File not found: C:\Websites\demo\bin\x64\imageflow.dll
Error The specified module could not be found loading imageflow from C:\Websites\demo\bin\imageflow.dll
File not found: C:\Websites\demo\bin\runtimes\win-x64\native\imageflow.dll
File not found: C:\Websites\demo\x64\imageflow.dll
File not found: C:\Websites\demo\imageflow.dll
File not found: C:\Websites\demo\runtimes\win-x64\native\imageflow.dll
File not found: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\demo\07ba4e9d\500187f\assembly\dl3\ab715b07\00a3d764_0890d601\x64\imageflow.dll
File not found: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\demo\07ba4e9d\500187f\assembly\dl3\ab715b07\00a3d764_0890d601\imageflow.dll
File not found: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\demo\07ba4e9d\500187f\assembly\dl3\ab715b07\00a3d764_0890d601\runtimes\win-x64\native\imageflow.dll
   at Imageflow.Bindings.NativeMethods.imageflow_context_create(UInt32 imageflow_abi_ver_major, UInt32 imageflow_abi_ver_minor)
   at Imageflow.Bindings.NativeLibraryLoader.FixDllNotFoundException[T](String basename, Func`1 invokingOperation, IEnumerable`1 customSearchDirectories)

Stack Trace:    at Imageflow.Bindings.LoadLogger.RaiseException()
   at Imageflow.Bindings.NativeLibraryLoader.FixDllNotFoundException[T](String basename, Func`1 invokingOperation, IEnumerable`1 customSearchDirectories)
   at Imageflow.Bindings.JobContextHandle..ctor()
   at Imageflow.Bindings.JobContext..ctor()
   at Imageflow.Fluent.ImageJob.<GetImageInfo>d__50.MoveNext()

Thank you for looking into this so quickly yesterday.

lilith commented 3 years ago

Can you re-verify that imageflow.dll is present?

On Mon, Sep 21, 2020, 5:31 AM thecaptncode notifications@github.com wrote:

Yes, I had to copy the imageflow.dll manually. It did not copy automatically.

I tried the updated DLL and it did not work. Here is the error I received.

Looking for "imageflow.dll" RID="win-x64", IsUnix=False, IsDotNetCore=False RelativeSearchPath="C:\Websites\demo\bin" Before searching: Unable to load DLL 'imageflow': The specified module could not be found. (Exception from HRESULT: 0x8007007E) File not found: C:\Websites\demo\bin\x64\imageflow.dll Error The specified module could not be found loading imageflow from C:\Websites\demo\bin\imageflow.dll File not found: C:\Websites\demo\bin\runtimes\win-x64\native\imageflow.dll File not found: C:\Websites\demo\x64\imageflow.dll File not found: C:\Websites\demo\imageflow.dll File not found: C:\Websites\demo\runtimes\win-x64\native\imageflow.dll File not found: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\demo\07ba4e9d\500187f\assembly\dl3\ab715b07\00a3d764_0890d601\x64\imageflow.dll File not found: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\demo\07ba4e9d\500187f\assembly\dl3\ab715b07\00a3d764_0890d601\imageflow.dll File not found: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\demo\07ba4e9d\500187f\assembly\dl3\ab715b07\00a3d764_0890d601\runtimes\win-x64\native\imageflow.dll at Imageflow.Bindings.NativeMethods.imageflow_context_create(UInt32 imageflow_abi_ver_major, UInt32 imageflow_abi_ver_minor) at Imageflow.Bindings.NativeLibraryLoader.FixDllNotFoundException[T](String basename, Func1 invokingOperation, IEnumerable1 customSearchDirectories)

Stack Trace: at Imageflow.Bindings.LoadLogger.RaiseException() at Imageflow.Bindings.NativeLibraryLoader.FixDllNotFoundException[T](String basename, Func1 invokingOperation, IEnumerable1 customSearchDirectories) at Imageflow.Bindings.JobContextHandle..ctor() at Imageflow.Bindings.JobContext..ctor() at Imageflow.Fluent.ImageJob.d__50.MoveNext()

Thank you for looking into this so quickly yesterday.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/imazen/imageflow-dotnet/issues/20#issuecomment-696057695, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA2LHYY4MUAOSXAYFH5PBLSG42S5ANCNFSM4RTZ42HQ .

thecaptncode commented 3 years ago

I verified that both dlls are in the ~/bin folder:

07/05/2020  03:32 PM         4,944,384 imageflow.dll
09/21/2020  07:14 AM           173,056 Imageflow.Net.dll
lilith commented 3 years ago

It's trying to load the dll from the right location at least. Which means it's either a corrupt file, the wrong bitness, or doesn't have the right NTFS permissions.

On Mon, Sep 21, 2020, 7:53 AM thecaptncode notifications@github.com wrote:

I verified that both dlls are in the ~/bin folder:

07/05/2020 03:32 PM 4,944,384 imageflow.dll 09/21/2020 07:14 AM 173,056 Imageflow.Net.dll

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/imazen/imageflow-dotnet/issues/20#issuecomment-696129505, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA2LH7XADC2OGJTOMUVCI3SG5LHPANCNFSM4RTZ42HQ .

lilith commented 3 years ago

Or, a fourth reason - you don't have the C Runtime installed.

Please take this step separately so we know what resolved the problem. https://aka.ms/vs/16/release/vc_redist.x64.exe

thecaptncode commented 3 years ago

Yes! That solved the problem. I did not realize that was prerequisite. Thanks so much for your help. I really appreciate it.

lilith commented 3 years ago

The C Runtime is generally installed on Windows by default. What version of Windows were you running? Any idea why the Universal CRT was missing?

thecaptncode commented 3 years ago

Production is running a decade old OS Windows Web Server 2008 R2. We have plans to upgrade soon. I spoke to ops and they did not know why it was missing. Was it automatically installed back then?

lilith commented 3 years ago

I don't think it auto-installs on WS2008R2, no.