0

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...

Community
  • 1
  • 1
Arad Zulti
  • 13
  • 5
  • 1
    WMP is included with the operating system. You must not, and cannot, embed the DLLs it uses. It is a COM component and that requires an interop library to make it usable from a .NET program. .NET 4 and VS2010+ have the "Embed Interop Types" feature, no dependency on the interop library anymore. – Hans Passant Oct 27 '16 at 15:32
  • I didn't understand the "Embed Interop Types" option. Can you explain it to me? – Arad Zulti Oct 27 '16 at 18:19
  • Select the WMP reference, look in the Properties window for the option. VS2010 or greater required. – Hans Passant Oct 27 '16 at 18:26
  • I meant, Can you explane me what is it doing? – Arad Zulti Oct 27 '16 at 18:39

1 Answers1

0

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.

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.
halfer
  • 19,824
  • 17
  • 99
  • 186
  • To answer to your question about what does "Embed Interop Types" option in reference properties : It embeds in your exe all Interop that are needed to use COM assemblies. – Mathieu Wybrecht Oct 28 '16 at 06:38
  • You're welcome ;) I did not know that WMP dll was concerned by interop, so thanks to @Hans-Passant for his message about that ! – Mathieu Wybrecht Oct 28 '16 at 15:00