Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Store a xml inside a compiled DLL

I want to store configuration information about my DLL in an XML file inside my DLL i.e. if changes need to be made the DLL must be re-compiled.

The reason is because its a elegant format and I may not use config files for this DLL.

Any ideas? I literally want to be able to edit an xml in Visual Studio then compile it and only see a DLL in the output.

like image 460
TheLearner Avatar asked Sep 03 '09 15:09

TheLearner


2 Answers

Yup - include it as an Embedded Resource (i.e. use that setting in the Properties for the item in Visual Studio), then use Assembly.GetManifestResourceStream to read it.

I do this all the time for unit test data. As you say, you can just edit the file, rebuild, and it'll be there.

like image 153
Jon Skeet Avatar answered Oct 16 '22 09:10

Jon Skeet


I wanted to make a small addendum to Jon's answer. Embedded Resource is the value of the Build Action property on the Properties panel.

like image 1
Ax. Avatar answered Oct 16 '22 10:10

Ax.