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.
我想将关于我的DLL的配置信息存储在我的DLL内的XML文件中,即如果需要进行更改,则必须重新编译DLL。
The reason is because its a elegant format and I may not use config files for this DLL.
原因是因为它的格式优雅,我可能不会使用此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.
有任何想法吗?我真的希望能够在Visual Studio中编辑一个xml然后编译它,只在输出中看到一个DLL。
2 个解决方案
#1
9
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.
是 - 将其包含为嵌入式资源(即在Visual Studio中的项目的属性中使用该设置),然后使用Assembly.GetManifestResourceStream来读取它。
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.
我一直这样做单元测试数据。正如你所说,你可以只编辑文件,重建,它就会存在。
#2
1
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.
我想对Jon的回答做一个小补遗。嵌入式资源是“属性”面板上“构建操作”属性的值。
#1
9
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.
是 - 将其包含为嵌入式资源(即在Visual Studio中的项目的属性中使用该设置),然后使用Assembly.GetManifestResourceStream来读取它。
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.
我一直这样做单元测试数据。正如你所说,你可以只编辑文件,重建,它就会存在。
#2
1
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.
我想对Jon的回答做一个小补遗。嵌入式资源是“属性”面板上“构建操作”属性的值。