无法从已编译的 ASP.NET 程序集中检索嵌入图像
我有一个简单的项目,其名称空间为“搜索”,其中包含许多已标记为嵌入资源的图像。
在使用 Reflector 检查引用以确保图像位于程序集中后,我已将其输入到 Assembly.vb 中。我已将图像“whole.gif”放置在应用程序的根目录中。
<Assembly: System.Web.UI.WebResource("Search.whole.gif", "image/gif")>
我渲染图像的代码如下,按理说它应该渲染图像,但没有,而且我一生都看不出为什么。
Private Sub Page_PreRender(sender As Object, e As System.EventArgs) Handles Me.PreRender
btnImgAll.ImageUrl = Page.ClientScript.GetWebResourceUrl(Me.GetType(), "Search.whole.gif")
End Sub
I have a simple project with a namespace of 'Search' which contains a number of images which have been marked as embedded resources.
I've entered this into Assembly.vb after checking the reference with Reflector to ensure the image is in the assembly. I've placed the image 'whole.gif' in the root of the application.
<Assembly: System.Web.UI.WebResource("Search.whole.gif", "image/gif")>
My code to render the image is below, it should by rights render the image but doesn't and I can't for the life of me see why.
Private Sub Page_PreRender(sender As Object, e As System.EventArgs) Handles Me.PreRender
btnImgAll.ImageUrl = Page.ClientScript.GetWebResourceUrl(Me.GetType(), "Search.whole.gif")
End Sub
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现问题引用了类型,几乎我能找到的每个示例都使用 Me.GetType()。除了检查这个论点之外,我还追寻了所有其他途径,直到我在论坛帖子中偶然发现了一条评论。
我将该行更改
为
Content_Modules_RegionSelector 是父控件的类名,在我的例子中是一个简单的 Web 用户控件。
I found the problem reference to the type which is almost every example given I could find uses Me.GetType(). I chased every other avenue aside from checking this argument until I can across a chance remark in a forum post.
I changed the line
to
where Content_Modules_RegionSelector is the class name of the parent control, which in my case is a simple web user control.