By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,572 Members | 2,949 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,572 IT Pros & Developers. It's quick & easy.

Embedded Resource (PNG) in DLL

P: n/a
Hi all, I've been strugling with this for the last few days and I'm wonding
if any of you have had the same problem or a solution I could consider: I'm
embedding a bitmap resource (PNG format) as part of an extended panel control
that I'm creating. I'm trying read the embedded resource and draw it out on
the panel. The drawing part I know how to do well enough, but for some reason
when I try to access the embedded resource (PNG = "header_image.png") it
always returns an empty stream (using helper methods wrapping
GetManifestResource...). I'm stumped. Please help!
--
Message posted via http://www.dotnetmonster.com
Nov 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
do you have the root namespace before the resource name? example
MyRootNamespace.picture.png
"Chris Murphy via DotNetMonster.com" <fo***@nospam.DotNetMonster.com> wrote
in message news:50***********@DotNetMonster.com...
Hi all, I've been strugling with this for the last few days and I'm
wonding
if any of you have had the same problem or a solution I could consider:
I'm
embedding a bitmap resource (PNG format) as part of an extended panel
control
that I'm creating. I'm trying read the embedded resource and draw it out
on
the panel. The drawing part I know how to do well enough, but for some
reason
when I try to access the embedded resource (PNG = "header_image.png") it
always returns an empty stream (using helper methods wrapping
GetManifestResource...). I'm stumped. Please help!
--
Message posted via http://www.dotnetmonster.com

Nov 21 '05 #2

P: n/a
I have some methods that take care of that

Private AppAssembly As Reflection.Assembly = Reflection.Assembly.
GetExecutingAssembly()
Private AppAssemblyPath As String = Me.AppAssembly.GetName().Name().
Replace(" ", "_")

Private Function GetResource(ByVal FileName As String) As System.IO.
Stream
Try
Return Me.AppAssembly.GetManifestResourceStream(Me.
AppAssemblyPath & "." & FileName)
Catch ex As Exception
MessageBox.Show("Error returning resource: " & ex.ToString(),
"XiNK!", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return Nothing
End Try
End Function

Brian Henry wrote:
do you have the root namespace before the resource name? example
MyRootNamespace.picture.png
Hi all, I've been strugling with this for the last few days and I'm
wonding

[quoted text clipped - 9 lines]
always returns an empty stream (using helper methods wrapping
GetManifestResource...). I'm stumped. Please help!

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...b-net/200506/1
Nov 21 '05 #3

P: n/a
Your app assembly path idea is flawed. Do as Brian suggested and use the
root namespace as declared in your project. See Windows Forms Tips and
Tricks for an article on how to find resources.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Chris Murphy via DotNetMonster.com" <fo***@DotNetMonster.com> wrote in
message news:50***********@DotNetMonster.com...
I have some methods that take care of that

Private AppAssembly As Reflection.Assembly = Reflection.Assembly.
GetExecutingAssembly()
Private AppAssemblyPath As String = Me.AppAssembly.GetName().Name().
Replace(" ", "_")

Private Function GetResource(ByVal FileName As String) As System.IO.
Stream
Try
Return Me.AppAssembly.GetManifestResourceStream(Me.
AppAssemblyPath & "." & FileName)
Catch ex As Exception
MessageBox.Show("Error returning resource: " & ex.ToString(),
"XiNK!", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return Nothing
End Try
End Function

Brian Henry wrote:
do you have the root namespace before the resource name? example
MyRootNamespace.picture.png
Hi all, I've been strugling with this for the last few days and I'm
wonding

[quoted text clipped - 9 lines]
always returns an empty stream (using helper methods wrapping
GetManifestResource...). I'm stumped. Please help!

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...b-net/200506/1

Nov 21 '05 #4

P: n/a
Your app assembly path idea is flawed. Do as Brian suggested and use the
root namespace as declared in your project. See Windows Forms Tips and
Tricks for an article on how to find resources.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Chris Murphy via DotNetMonster.com" <fo***@DotNetMonster.com> wrote in
message news:50***********@DotNetMonster.com...
I have some methods that take care of that

Private AppAssembly As Reflection.Assembly = Reflection.Assembly.
GetExecutingAssembly()
Private AppAssemblyPath As String = Me.AppAssembly.GetName().Name().
Replace(" ", "_")

Private Function GetResource(ByVal FileName As String) As System.IO.
Stream
Try
Return Me.AppAssembly.GetManifestResourceStream(Me.
AppAssemblyPath & "." & FileName)
Catch ex As Exception
MessageBox.Show("Error returning resource: " & ex.ToString(),
"XiNK!", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return Nothing
End Try
End Function

Brian Henry wrote:
do you have the root namespace before the resource name? example
MyRootNamespace.picture.png
Hi all, I've been strugling with this for the last few days and I'm
wonding

[quoted text clipped - 9 lines]
always returns an empty stream (using helper methods wrapping
GetManifestResource...). I'm stumped. Please help!

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...b-net/200506/1

Nov 21 '05 #5

P: n/a
I id just that, thank you!

Bob Powell [MVP] wrote:
Your app assembly path idea is flawed. Do as Brian suggested and use the
root namespace as declared in your project. See Windows Forms Tips and
Tricks for an article on how to find resources.
I have some methods that take care of that

[quoted text clipped - 23 lines]
always returns an empty stream (using helper methods wrapping
GetManifestResource...). I'm stumped. Please help!

--
Message posted via http://www.dotnetmonster.com
Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.