为什么GetManifestResourceStream返回null同时呼吁GetManifestResourceNames当资源名称存在? [英] Why does GetManifestResourceStream returns null while the resource name exists when calling 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.
- 我加入
site_export.master
,并改变了它的生成操作嵌入的资源。 - 我改变了我的页面中使用新网站的主人。
-
GetManifestResourceStream()
收益空
当我加载site_export.master
。 - 我称之为
GetManifestResourceNames()
检查site_export.master
存在的DLL和它。这是在列表中。所有的名称空间相匹配。我没有列出名字空间在这里。
- I added
site_export.master
and changed its Build Action to Embedded Resource. - I changed my page to use the new site master.
GetManifestResourceStream()
returnsnull
when I loadsite_export.master
.- I call
GetManifestResourceNames()
to check ifsite_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屋!