I'm developing a .NET app using Visual Studio Community 2015, which uses some of the AForge.NET libraries. I added the references to my project, and when I debug the app the libraries work fine. However, when I publish the app and install it in the same computer, as soon as I reach a part of the application in which the AForge.NET libraries are used, the app crashes with the following error:
System.IO.FileNotFoundException: Could not load file or assembly 'AForge.Video.FFMPEG.dll' or one of its dependencies. The specified module could not be found.
Filename: 'AForge.Video.FFMPEG.dll'
on MyApp.mySecondForm..ctor(Int32 id)
on MyApp.myMainForm.myListView_DoubleClick(Object sender, EventArgs e)
on System.Windows.Forms.Control.OnDoubleClick(EventArgs e)
on System.Windows.Forms.ListView.WndProc(Message& m)
on System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
on System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
on System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
I've searched online for solutions to this, and so far none of the following has worked for me:
Also, I searched for the folder where the app was installed, and I see all the DLL files are there, each in a different folder, along with a single folder with every DLL among other files.
I have no issues with other libraries (the ones in the Global Assembly Cache), such as MySql.Data
.
Following a suggestion by Chris O, I used the Process Monitor to check on my app, and it shows it's looking for the AForge libraries in the GAC; since I haven't added them there, there's no way they can be found.
What do I need to do in order to configure my app so it can access the libraries from an app folder instead of looking for them in the GAC?
The AForge.Video
library includes a few external DLL files that cannot be added as references. Instead, they must be copied to the bin folder of the project. Likewise, after installing the app, they must be copied to the folder where the other DLL files reside. The exact name of the folder varies, but in my case, I had to copy them to the following directory:
C:\Users\ User Name \AppData\Local\Apps\2.0\3V9YACJD.EPJ\V4BGBR0L.485\appe..tion_0000000000000000_0001.0008_b483b48e9712fa89
The DLL files that need to be copied are:
I noticed this after making the same app as a new Visual Studio project, and forgetting to copy the external libraries in the new project, which caused the same error in development (which I didn't get before).
add useLegacyV2RuntimeActivationPolicy="true"
on app.config
after startup
like
`<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>`
and copy AForge external dll in Externals\ffmpeg\bin to project bin\debug folder.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With