我想一些XML文件作为资源添加到我的类库项目。 任何想法如何做到这一点的,后来打电话吗? 在Windows应用程序中,我会做这样 ClassLibrary1.Properties.Resources.file.xml
不过,这并没有任何工作的想法我怎么在这里?
解决方案本文解释使用嵌入的资源在C#。
它归结为
VAR组装= Assembly.GetExecutingAssembly();
VAR流= _assembly.GetManifestResourceStream(fully.qualified.name.of.the.resource);
如果你正在努力制定出资源的FQ名字,一个偷懒的办法是使用的反射来打开保存它的组件。转到资源文件夹,右键单击特定资源,选择复制。
I want to add some xml file as resource to my class library project . Any idea how to do so , and call it later? In windows application i would do it like ClassLibrary1.Properties.Resources.file.xml
But here it didn't worked any idea how i do it here ?
解决方案This article explain how to use embedded resources in C#.
It boils down to
var assembly = Assembly.GetExecutingAssembly();
var stream = _assembly.GetManifestResourceStream("fully.qualified.name.of.the.resource");
If you're struggling to work out the fq name of the resource, a lazy way is to use the reflector to open the assembly that holds it. Go to the Resources folder, right click on the particular resource and choose 'Copy'.
更多推荐
在类库项目资源
发布评论