简体   繁体   English

无法在共享项目中加载资源文件

[英]Can't load resource file in Shared project

I have two project - shared project and wpf project. 我有两个项目-共享项目和wpf项目。 And there is a html file in shared project. 共享项目中有一个html文件。 I want to get stream of the file using below code. 我想使用以下代码获取文件流。

var resourceName = String.Format("{0}.Map.html", this.GetType().Namespace);
Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName)

But It returns null always. 但是它总是返回null。 I checked resource names with below code. 我用以下代码检查了资源名称。

var names = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceNames();

I can't see the html file from the list. 我从列表中看不到html文件。 I added the file with Add Existing Item Dialog. 我使用“添加现有项”对话框添加了文件。 I'm not sure. 我不确定。 What is wrong. 怎么了。 Please help me. 请帮我。 Thanks 谢谢

I found the solution. 我找到了解决方案。 select the resource file and in the property window change build action with embedded resource. 选择资源文件,然后在属性窗口中更改带有嵌入式资源的构建操作。 It's working perfectly. 运行良好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM