Arad Zulti Arad Zulti - 1 month ago 15
C# Question

Add Windows Media Player Dll to EXE

I built an application that used some extrnal libraries, Like Tag-lib, Naudio and Windows Media Player.

So they add me to my solution (in the same folder as my EXE file), some DLLs.

I wanted to embed those DLLs to my EXE file, so I looked at the internet and found some options.

The best answer I found was this:

Embedding DLLs in a compiled executable

And it worked, but not for all of the DLLs.

It successfully embedded Naudio and Tag-Lib, But Unabled to embed Windows Media Player's DLLs.

Can anyone help me embed the Windows Media Player's DLLs to my application's EXE?

Update:

After some help (Thanks Mathieu Wybrecht) it worked.
I did everything that he said, but still it isn't working well.
The EXE file work perfectlly, I can move him and it will work.
But when I'm in the project's solution, it error me about the missing Dlls (The Dlls of WMP that Costura.Fody just embed...), and then I copy the Dll again to the folder and the error gone. It seccessed to build the solution, rebuild the solution or starting the program, the DLLs Disapear again (embed to the EXE) and the error comes up again...

Answer

Your question is not clear. What do you mean by "when I started to use Windows Media Player, it added a DLL file, and now it doesn't ..."

  • Where did "it" add a DLL file ?
  • What is "it" ? Your application ? Windows Media Player ?
  • What DLL was added ?

If the problem is that you want to embed one more DLL in your exe, follow the how-to you found about Costura.Fody,

If the problem occurs at run time, ensure that all embedded DLL don't try to load more dependencies. You can check for their dependencies using "Dependency Walker", it exists for x86 and x64 platform.

Come back with more infos and we'll try to help you better !

edit : you edited your question, and now I'm back to edit my answer too :)

So. You succeeded to embed few DLL but not every one of them. It can be related to some of following reasons :

  • Some of them are native DLL (you have to follow a particular process to embed) : you may refer to Fody/Costura unmanaged assemblies and Fody/Costura Native Libraries
  • For some of them, Reference in your project are maybe not marked as "Copy Local = true" and/or not considered as "Embeded Resources" for some reason
  • Maybe your library is correctly embedded but still present in your output directory for you may not have installed the clean-output target ? take a look at : Clean output directory
  • Or you may face another problem that is more specific, try to get a look at Fody/Costura issues, you may find a reason for which your desired libraries are not embedded ...

May I have helped you, please feel free to upvote. Otherwise, try to send a minimal VS project which will let me maybe reproduce the issue and identify the exact problem.