Kat
Kat

Reputation: 4695

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.

Upvotes: 5

Views: 6322

Answers (3)

s.k.paul
s.k.paul

Reputation: 7291

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>

Upvotes: 2

Mike Upjohn
Mike Upjohn

Reputation: 1297

I've found that this error was resolved when I did the following steps (with AForge DLL's in your project and referenced):-

  1. Right Click your Project --> Select Properties
  2. Click Build (on the left)
  3. Change Platform target to X86

See if this helps, it worked for me!

Upvotes: 1

Kat
Kat

Reputation: 4695

I've found a solution. For whatever reason, putting the FFmpeg DLLs (avformat-53.dll, avutil-51.dll, etc) in the C:\Windows\System32 folder works.

I don't understand why the DLLs can't simply be in the PATH. Also, it's quite inconvenient to be placing DLLs in this location.

Due to how unideal this is, I'm going to hold off accepting this as the answer, in hopes that someone else can give a better solution or at least explain why the PATH or System32 did not work.

Upvotes: 1

Related Questions