为什么GetManifestResourceStream返回null同时呼吁GetManifestResourceNames当资源名称存在? [英] Why does GetManifestResourceStream returns null while the resource name exists when calling GetManifestResourceNames?

查看:203
本文介绍了为什么GetManifestResourceStream返回null同时呼吁GetManifestResourceNames当资源名称存在?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Web应用程序项目。我生成的DLL和在另一个项目中导入。我实现了的VirtualPathProvider

I have a web application project. I generated the DLL and import it in another project. I implemented VirtualPathProvider.

我跟着这个网站:<一href=\"http://support.microsoft.com/kb/910441/en-us?spid=8940&sid=global\">http://support.microsoft.com/kb/910441/en-us?spid=8940&sid=global,一切工作,直到我添加其他网站的主人。

I followed this web site: http://support.microsoft.com/kb/910441/en-us?spid=8940&sid=global, and everything works until I add another site master.


  1. 我加入 site_export.master ,并改变了它的生成操作嵌入的资源。

  2. 我改变了我的页面中使用新网站的主人。

  3. GetManifestResourceStream()收益当我加载 site_export.master

  4. 我称之为 GetManifestResourceNames()检查 site_export.master 存在的DLL和它。这是在列表中。所有的名称空间相匹配。我没有列出名字空间在这里。

  1. I added site_export.master and changed its Build Action to Embedded Resource.
  2. I changed my page to use the new site master.
  3. GetManifestResourceStream() returns null when I load site_export.master.
  4. I call GetManifestResourceNames() to check if site_export.master exists in the DLL and it does. It's in the list. All of the name spaces match. I didn't list the name space out here.

为什么不能 GetManifestResourceStream()加载我新的 site_export.master ?它加载的Site.Master 就好了。我知道我的DLL被加载,因为我可以在DLL中看到的其他文件。

Why can't GetManifestResourceStream() load my new site_export.master? It loads site.master just fine. I know my DLL is loaded because I can see other files in the DLL.

推荐答案

记住以下几个问题...

Remember the following issues...

第1步的。构建操作设置为嵌入的资源参见

Step 1. Build action set to embedded resource see

C#的GetManifestResourceStream疑难杂症

第2步的。使用 namespace.resourcename 看<一个href=\"http://nullfork.blogspot.com/2011/09/getmanifestresourcestream-returns-null.html\">GetManifestResourceStream()返回null?

其实,如果在其他程序集的私有资源被访问和调用方不具有此方法返回null 性ReflectionPermission ReflectionPermissionFlag.MemberAccess 标记。

Actually, this method returns null if a private resource in another assembly is accessed and the caller does not have ReflectionPermission with the ReflectionPermissionFlag.MemberAccess flag.

这篇关于为什么GetManifestResourceStream返回null同时呼吁GetManifestResourceNames当资源名称存在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆