Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I include a .jpg into a dll?

I have a third-party application that creates a dll file out my .cs code.

In my .cs code I reference a file.

How do I compile the dll or .cs to include the .jpg file along with the code?

The options I have for the third-party application does not allow me to export the .jpg

The import process only looks at the .cs and the associated .dll.

Is there a way to add the file to the dll once the third-party application has created the dll in the export process with visual stuido or something?

like image 214
lakersfan Avatar asked Nov 06 '25 04:11

lakersfan


1 Answers

Yes this is possible. If the file is used by your code in the dll then the file needs to be embedded thorugh the Properties >> Build Action >> Embedded Resource setting:

enter image description here

(EDIT) Visual Studio Code variant

You have to edit the .csproj and change the node that represents your file to:

<EmbeddedResource Include="Resources\yourEmbeddedResource.json" />

Source:

  1. https://starbeamrainbowlabs.com/blog/article.php?article=posts/180-Embedding-Resources.html;
  2. https://www.codeproject.com/Articles/114997/Embedding-and-Using-Resources-from-Net-Assembly;
  3. How to mark a file as an embedded resource in Visual Studio Code?;
like image 141
Iliass Akkara Avatar answered Nov 08 '25 06:11

Iliass Akkara