Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to load AForge.Video.FFMPEG for ASP.NET application when it worked for a Windows Form application

I am getting the following error:

ASP.NET runtime error: Could not load file or assembly 'AForge.Video.FFMPEG.DLL' or one of its dependencies. The specified module could not be found.

I had this working in a Windows Forms project but after trying to convert the project to an ASP.NET one, I've been unable to get it to run. I was using a 64 bit DLL there, but have switched to using a 32 bit DLL now because I seem to be making more progress with that (got a similar error with the 64 bit DLL).

I've set the platform target to x86 in project properties and have also tried setting it to any CPU (which triggers warnings since the DLLs are native 32 bit) and have also tried changing the target to x64 while using the 64 bit DLLs.

In the IIS application pool, I have "Enable 32-Bit Applications" set to be true. Removing this one DLL causes the project to work and adding it back in causes it to fail.

I've tried:

  1. Putting the DLLs in System32.
  2. Putting the bin folder (with the DLLs) in the PATH.
  3. Setting the application target to all possible choices (x86, x64, any CPU).
  4. Verified the DLL is not corrupted and even tried one compiled by a different source.
  5. All the FFMPEG DLLs are in the bin folder; also tried putting them in System32.

There's no code even using the DLLs in this project (I have code in a Windows Forms project that I'm going to merge into this, but I can't do that if the references don't even work). I've even created new projects in case there's some weird artefact in the projects.

Note that I've read pretty much every Google result related to this DLL and ASP.NET. None of the approaches seem to work.

like image 880
Kat Avatar asked Sep 27 '22 22:09

Kat


1 Answers

I faced the same problem. Now it's working nice. I did couple of things. Though I am not sure which one was actually made my application working.

  1. Copied DLLs from "Externals\ffmpeg\bin" to project's output directory (where executable stays);
  2. Also copied those .dlls in C:/Windows/System32 directory.
  3. Set built for x86 target (runs in 32-bit mode).
  4. Though my project was based on framework 4.5, I also installed v3.5.
  5. Finally, I added useLegacyV2RuntimeActivationPolicy="true" in app.config -
 <?xml version="1.0" encoding="utf-8"?>
 <configuration>
   <startup useLegacyV2RuntimeActivationPolicy="true"> //useLegacyV2RuntimeActivationPolicy for older .net version
      <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
   </startup>    
 </configuration>
like image 115
s.k.paul Avatar answered Nov 15 '22 07:11

s.k.paul