473,386 Members | 1,706 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,386 software developers and data experts.

Reflection / Resource file issue

Hi all,

I've been banging my head trying to figure out what I'm missing here. I
downloaded a control that uses a stream derived from a bitmap file. What I
can't seem to figure out is where it's getting its location for the bmp.
Physically, it is located in a Resources\Images folder under the project
root. In the project, this same folder structure is referenced (so the
treeview shows a Resources folder containing an Images subfolder and the
bitmap contained within).

The example then uses
Assembly.GetManifestResourceStream("MyNameSpace.Re sources.Images.MyFile.bmp");

When I attempt to duplicate this functionality, the above function returns a
stream of an "<undefined value>". I've checked names, compared the resx
files and directory structures with no luck. I've done very little with
reflection and resource files so am probably missing something stupid.

Any suggestions?

Thanks,

John

Nov 22 '05 #1
4 1691
Firstly, the name is case sensitive, so make sure your case matches.

Secondly, the folder structure in the project is not reflected in the
resource name. Generally, you would use the root namespace of the
project followed by the image name such as: MyNameSpace.MyFile.bmp,
being sure to match the case.

Hope this helps

Nov 22 '05 #2
Hi Chris,

Thanks for the tips. I've checked the case and tried a number of variations
on NameSpace.FileName.bmp, but still no luck.

- John

"Chris Dunaway" <du******@gmail.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
Firstly, the name is case sensitive, so make sure your case matches.

Secondly, the folder structure in the project is not reflected in the
resource name. Generally, you would use the root namespace of the
project followed by the image name such as: MyNameSpace.MyFile.bmp,
being sure to match the case.

Hope this helps

Nov 22 '05 #3
John Spiegel wrote:
The example then uses
Assembly.GetManifestResourceStream("MyNameSpace.Re sources.Images.MyFile.bmp");

When I attempt to duplicate this functionality, the above function returns a
stream of an "<undefined value>". I've checked names, compared the resx
files and directory structures with no luck. I've done very little with
reflection and resource files so am probably missing something stupid.


1) As has been mentioned, "MyFile.bmp" will be qualified by the
assembly's default namespace. (Assembly.GetManifestResourceNames()
will return all named resources in an assembly.)

2) The bitmap MUST be an "Embedded Resource" (Solution Explorer /
Properties / Build Action). When you add an image, it defaults to
"Content".

--

www.midnightbeach.com
Nov 22 '05 #4
#2 was the issue! Thanks, Jon. Sheesh .NET is a big language...

"Jon Shemitz" <jo*@midnightbeach.com> wrote in message
news:42***************@midnightbeach.com...
John Spiegel wrote:
The example then uses
Assembly.GetManifestResourceStream("MyNameSpace.Re sources.Images.MyFile.bmp");

When I attempt to duplicate this functionality, the above function
returns a
stream of an "<undefined value>". I've checked names, compared the resx
files and directory structures with no luck. I've done very little with
reflection and resource files so am probably missing something stupid.


1) As has been mentioned, "MyFile.bmp" will be qualified by the
assembly's default namespace. (Assembly.GetManifestResourceNames()
will return all named resources in an assembly.)

2) The bitmap MUST be an "Embedded Resource" (Solution Explorer /
Properties / Build Action). When you add an image, it defaults to
"Content".

--

www.midnightbeach.com

Nov 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: John Spiegel | last post by:
Hi all, I've been banging my head trying to figure out what I'm missing here. I downloaded a control that uses a stream derived from a bitmap file. What I can't seem to figure out is where...
11
by: Danny Pressley | last post by:
I have a VS.NET 2003 Visual C++ MFC Application Project in which I added a new resource file, I then added an icon to this new resource file and did a rebuild and got the following error: "fatal...
0
by: SHC | last post by:
Hi all, I saw the following 2 files used in the OpenGL and DirectX 9 programming: 1) resource.h //{{NO_DEPENDENCIES}} // Microsoft Visual C++ generated include file. // Used by...
0
by: Tyrven | last post by:
I have a localized website that has been in production for sometime. Recently, localizations for one particularly locale (zh-TW) stopped displaying on the test application; the same locale works...
2
by: Jeff | last post by:
I am trying to dynamically load an assembly via reflection and then invoke a method of that assembly that will populate a custom type collection passed into the method byref. I am able to...
1
by: Dom | last post by:
I get an InvalidOperationException with the message "The resource class for this page was not found. Please check if the resource file exists and try again." when I change the resource file of a...
0
by: npthomson | last post by:
Hi all, This could get a bit complicated but I'll try to be as clear as possible. I've written an application that discovers plugins at runtime using reflection from a subdirectory of the...
7
by: craig | last post by:
....quick question for anyone who might have some experience with .net resource files in VS 2003. I have an application that is not localized, but I would still like to be able to place all of...
7
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post by:
I have a C# logging assembly with a static constructor and methods that is called from another C# Assembly that is used as a COM interface for a VB6 Application. Ideally I need to build a file...
0
by: =?Utf-8?B?UGF1bCBIYWdlcg==?= | last post by:
I've been trying to solve this issue for the better part of a month. My attempts to get an answer on the MSDN groups proved to no avail. Here is the situation/problem. I am migrating an old...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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.