How do I include a .jpg into a dll?

断了今生、忘了曾经 提交于 2020-05-27 21:20:49

问题


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?


回答1:


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:

(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?;


来源:https://stackoverflow.com/questions/61805604/how-do-i-include-a-jpg-into-a-dll

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!