473,322 Members | 1,421 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,322 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 1690
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.