473,387 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Embedded Resource (PNG) in DLL

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
5 5781
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: james | last post by:
What class / method should I be using to get the full path to an embedded resource ? In my case I have an .xml file that my app uses, it is set as embedded resource, and I have a control that...
5
by: Drew | last post by:
Assembly asm = Assembly.GetExecutingAssembly(); me = new Bitmap(asm.GetManifestResourceStream("me.gif")); I have used this before without any problem, but now I get: An unhandled exception...
2
by: Kyle Kaitan | last post by:
I have an assembly (AppResources.dll) which contains a number of embedded resource files. Most of these are key/value pairs of relevant strings; a few are images and sounds; some more are XML...
0
by: Johann Blake | last post by:
I'm having trouble grasping how ASP.NET correctly locates resources. There is plenty of documentation on this subject but some things are not clear at all. In my ASP.NET application, I have...
2
by: Chris Murphy via DotNetMonster.com | last post by:
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...
4
by: Jason Pettys | last post by:
In an ASP.NET project I am setting the content type of my .ascx and ..aspx files to Embedded Resource for a separate reason. When I do this they get embedded as "RootNamespace.Filename" but I...
3
by: C-Services Holland b.v. | last post by:
Hi all, I've created a custom button which I can stick into my toolbox. This all works well and I see my button in the designer. This button uses customised graphics and I want to stick it in...
2
Frinavale
by: Frinavale | last post by:
I am attempting to use embedded resources in an Ajax Enabled ASP.NET Web Application. I'm using Visual Studio 2008 and VB.NET server side code. The project is called "EmbeddedResources" with the...
2
by: steve | last post by:
I have the following routine for retrieving error message strigs from a resource file which is embedded in the project. But when it is called I get the error messsage "Could not find any...
0
by: raylopez99 | last post by:
I have a minor problem locating an image file to load as a Bitmap. A resource file "NudeSusan.jpeg" (which I think is actually a bmp file, originally taken from a jpeg of model Susan Spears) is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.