AForge.NET

  :: AForge.NET Framework :: Articles :: Forums ::

Creating single exe with Aforge.Video.FFMPEG not working

Forum to discuss AForge.NET Framework, its features, API, how-tos, etc.

Creating single exe with Aforge.Video.FFMPEG not working

Postby DSZ » Fri Mar 29, 2019 8:32 am

I was able to create single exe for my WinForm app using Costura and Fody (Any CPU .NET 4).
All dll files used in my project are placed in a 'dll' folder inside project. And Build Action of each dll is set to none. Then each dll in this folder is added as a reference.
Now I want to add Aforge.Video.FFMPEG.dll as reference and did as above. But when running the app it shows an exception :

System.IO.FileLoadException: 'Could not load file or assembly 'AForge.Video.FFMPEG, Version=2.2.5.0, Culture=neutral, PublicKeyToken=03563089b1be05dd' or one of its dependencies. Attempt to load an unverifiable executable with fixups (IAT with more than 2 sections or a TLS section.) (Exception from HRESULT: 0x80131019)'


Finally I found that FFMPEG has 8 native dlls and this files should put in bin/Release folder along with Aforge.Video.FFMPEG.dll. Then I can only run the app.

Is there any way to execute the app without putting AForge.Video.FFMPEG.dll and 8 native dll in bin folder?
Also Fody not embedding those native dll. How can I embed this FFMPEG to fody to create a single exe file?
Attachments
stack.PNG
stack.PNG (46.3 KiB) Viewed 679 times
stack2.PNG
putting native dlls and ffmeg.dll inside bin/Release folder
stack2.PNG (56.78 KiB) Viewed 679 times
stack3.PNG
Used references in the app
stack3.PNG (48.95 KiB) Viewed 679 times
DSZ
 
Posts: 15
Joined: Mon Feb 25, 2019 7:06 am

Re: Creating single exe with Aforge.Video.FFMPEG not working

Postby andrew.kirillov » Fri Mar 29, 2019 8:55 am

DSZ wrote:Is there any way to execute the app without putting AForge.Video.FFMPEG.dll and 8 native dll in bin folder?

Where would you want to put them instead? The application needs those files to run successfully. If not in the same folder as your EXE file, they must be somewhere so the system could find them. Try this: Search Order for Desktop Applications

DSZ wrote:How can I embed this FFMPEG to fody to create a single exe file?

This would violate LGPL license requirement. Better read it.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3427
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: Creating single exe with Aforge.Video.FFMPEG not working

Postby DSZ » Fri Mar 29, 2019 9:52 am

Where would you want to put them instead?


I want to create single exe for my app. when I'm using other dlls of aforge I can run it without putting it in bin folder. Only need to add it as reference. But in case of ffmpeg.dll because of this native dlls I cant create single exe file
DSZ
 
Posts: 15
Joined: Mon Feb 25, 2019 7:06 am

Re: Creating single exe with Aforge.Video.FFMPEG not working

Postby andrew.kirillov » Fri Mar 29, 2019 10:54 am

OK, your definition of single EXE is just a bit confusing. When AForge.NET Framework is installed out of the official installer package, it adds its installation folder into the list of folders to look for .NET DLLs. So that is how those are found. FFmpeg native DLLs are not .NET though, so those are searched in a different way. Check the link I've sent before.

Anyway, you EXE is not independent anyway. If you put it on the system which does not have AForge.NET DLLs, then it will not run. I would not rely on what is installed on user’s system and distribute required dependencies as well.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3427
Joined: Fri Jan 23, 2009 9:12 am
Location: UK




Return to AForge.NET Framework