Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I embed other files in a DLL?

I'm writing a plug-in for another application through an API. The plug-ins are distributed a DLLs. Is it possible to embed other files in the DLL file like pdfs, images, chm help files etc... I want to be able to provide documentation with my plug-in but I'd still like to retain the ability to distribute the plug-in as a single file the user can just drag and drop onto the application to install.

like image 863
Eric Anastas Avatar asked Dec 11 '09 20:12

Eric Anastas


People also ask

Can a DLL contain other DLLs?

DLL dependenciesWhen a program or a DLL uses a DLL function in another DLL, a dependency is created. The program is no longer self-contained, and the program may experience problems if the dependency is broken.

How do I insert a DLL into another DLL?

Add DLL As Embedded Resource First, add the DLL as Reference. Then, add the same DLL as file into the project. Right click the project's name > Add > Existing Item... The same DLL will exist twice in different folder in the project.

What is DLL in embedded?

a .exe formatted file. Normally the code for a microcontroller or an embedded processor would be self-contained and stand-alone. A DLL is a shared library and to use it requires runtime intervention.


2 Answers

Sure, you can embed a resource in your DLL. Then at runtime you just do:

Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("com.stackoverflow.plugin.example.Foo.pdf");

This would give you a stream to the Foo.pdf file embedded in your DLL. Pay attention to the fact that the resource name has to be scoped by the namespace of the type from which you're invoking the method.

like image 192
Gregory Pakosz Avatar answered Oct 13 '22 23:10

Gregory Pakosz


Sure, just make them "Embedded Resource" in VS.NET (assuming you're using it). You can then read them via resource APIs or simply with Assembly.GetManifestResourceStream().

like image 21
Lucero Avatar answered Oct 13 '22 23:10

Lucero