473,943 Members | 16,002 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GetManifestReso urceStream returning NULL (Embedded Resource)

10 New Member
Hi,

I followed an example that loads an embedded resource
http://support.microso ft.com/kb/324567
That works just fine and dandy.

My problem is that my namespaces are setup a bit differently.
I tried using both namespaces and neither seem to work.

I'm assuming it shoud be the First_namespace , since that is the project namespace.
- The resource compile option is set to for embedded resource.


namespace First_namespace
{
using Second_namespac e;

public FirstClass()
{
DoSomething()
{
SecondClass _SecondClass;
_SecondClass.Lo ad();
}
}
}

namespace Second_namespac e
{
public SecondClass
{
public Load()
{
Stream st = this.GetType(). Assembly.GetMan ifestResourceSt ream("First_nam espace.RWZ.bmp" );
Stream tt = this.GetType(). Assembly.GetMan ifestResourceSt ream("Second_na mespace.RWZ.bmp ");
Bitmap myBitmap = new Bitmap(st);
st.Close();

}
}
}

TIA,
Dec 17 '07 #1
6 21680
Plater
7,872 Recognized Expert Expert
Normally this:
Expand|Select|Wrap|Line Numbers
  1. namespace First_namespace
  2. {
  3. using Second_namespace;
  4.  
  5. public FirstClass()
  6. {
  7. DoSomething()
  8. {
  9. SecondClass _SecondClass;
  10. _SecondClass.Load();
  11. }
  12. }
  13. }
  14.  
is done like this?
Expand|Select|Wrap|Line Numbers
  1. using Second_namespace;
  2. namespace First_namespace
  3. {
  4.  
  5. public FirstClass()
  6. {
  7. DoSomething()
  8. {
  9. SecondClass _SecondClass;
  10. _SecondClass.Load();
  11. }
  12. }
  13. }
  14.  
Dec 17 '07 #2
CSharpProgrammer
10 New Member
I suppose you could add all the using statements globally to the top.
Heck, I suppose you could even add every known using statement, whether you use them or not.

My intention is to seperate them into a more object oriented approach.
That way, I know what class is using some other class/namespace.
That is why I did it that way.

I don't really know how many namespaces or classes can be in one file or just how that is supposed to be formatted.

Your suggestion didn't seem to make a difference.
I think I am going to just make a really small file and post the actual code instead of what I have. I was just looking for a quick answer.

Thanks,

Normally this:
Expand|Select|Wrap|Line Numbers
  1. namespace First_namespace
  2. {
  3. using Second_namespace;
  4.  
  5. public FirstClass()
  6. {
  7. DoSomething()
  8. {
  9. SecondClass _SecondClass;
  10. _SecondClass.Load();
  11. }
  12. }
  13. }
  14.  
is done like this?
Expand|Select|Wrap|Line Numbers
  1. using Second_namespace;
  2. namespace First_namespace
  3. {
  4.  
  5. public FirstClass()
  6. {
  7. DoSomething()
  8. {
  9. SecondClass _SecondClass;
  10. _SecondClass.Load();
  11. }
  12. }
  13. }
  14.  
Dec 17 '07 #3
CSharpProgrammer
10 New Member
The following code works.
I don't know why mine doesn't?

I noticed that in "Project Properties", there is a "Default namespace".
The GetManifestReso urceStream() seems to be dependent upon that, rather than the the actual namespace.
*Note: WindowsApplicat ion1 -vs- Windows_Applica tion_1

I'll update the post if I ever figure out why mine doesn't want to work.
Though I think I am just going to move everything to the code that does work.

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8.  
  9. namespace WindowsApplication1
  10. {
  11.     using Second_namespace;
  12.  
  13.     public partial class Form1 : Form
  14.     {
  15.         public Form1()
  16.         {
  17.             InitializeComponent();
  18.         }
  19.  
  20.         private void button1_Click(object sender, EventArgs e)
  21.         {
  22.             Bitmap bmp = null;
  23.  
  24.             Second_Class _SecondClass = new Second_Class();
  25.             _SecondClass.LoadBMP(ref bmp);
  26.             Graphics g = CreateGraphics();
  27.             g.DrawImage(bmp, 0, 0);
  28.             bmp.Dispose();
  29.             g.Dispose();
  30.  
  31.         }
  32.     }
  33. }
  34.  
  35. namespace Second_namespace
  36. {
  37.     using System.IO;
  38.     using System.Drawing.Imaging;
  39.  
  40.     class Second_Class
  41.     {
  42.         public void LoadBMP(ref Bitmap bmp)
  43.         {
  44.             Stream s = this.GetType().Assembly.GetManifestResourceStream("Windows_Application_1.RWC.jpg");
  45.             bmp = new Bitmap(s);
  46.             s.Close();
  47.         }
  48.     }
  49.  
  50. }
Dec 17 '07 #4
CSharpProgrammer
10 New Member
I got it!!!

I created a folder and added the bmp/jpg Resouces to that folder,
So, I had to add the folder to the path.

Stream st = this.GetType(). Assembly.GetMan ifestResourceSt ream("Default_n amespace.Resources.RWC.jpg");

*Note the "Default_namespa ce", which is different from "First_namespace".
Which is what you will see in Project Properties.

Also, I noticed something that I don't quite understand just yet.
1. When a resource is added by using either Project->Add Existing Item,
or right clicking and selecting Add->Existing Item, it correctly adds the
image. But, when I click on the Project properties, it doesn't show up in the
Resources.

I am coming from a MFC/Visual C++ Environment.
When the image is added using Project->Properties->Resource, it requests a name for the image. I am used to doing that, instead of specifying the actual name.

Regards,
Dec 18 '07 #5
Plater
7,872 Recognized Expert Expert
How come you don't add it using the resource manager thing? Properties->Resources ?
Looking at that could could probably show you a nicer way to add/access resources?
Dec 18 '07 #6
CSharpProgrammer
10 New Member
I wasn't familiar with the Resource Manager.
I suppose that is the correct way to do it.
I thought I could just right click and add the resource.
It does work, it just doesn't show up in Resource Manager.

I wonder if you can add a folder to seperate the resources from the other files?
I will have to try that out.
This is my first time using Resources and I am fairly new to C#.

Thanks,

How come you don't add it using the resource manager thing? Properties->Resources ?
Looking at that could could probably show you a nicer way to add/access resources?
Dec 20 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
508
by: Steve Guidi | last post by:
Hello, I'm developing an application that periodically reads embedded assembly resources. The resources are text-based, and are about 3-7KB in size, and the application accesses them by calling the Assembly.GetManifestResourceStream() method. During a long period of execution, I've noticed that the memory usage of the application increases; specifically, it appears that the System.IO.__UnmanagedMemoryStream returned by
1
660
by: Mark Rae | last post by:
Hi, I'm writing a WinForms app in C# which requires a 3rd party executable called htmldoc.exe in order to create PDF documents from HTML files. To prevent the app from not functioning if the user accidentally deletes this file, I'm investigating the possibility of making it an Embedded Resource. When the app starts up, it will search for the executable and "extract" it if it's missing. I found the following code on the Net: using...
1
2961
by: n! | last post by:
I have an irritating problem with VS.NET2003, C#. I wrote some code that would build my application menu from an XML resource file. Purely to make it easy for me to edit, so I've added this file as an embedded resource. My irritation, is that when I update the resource file and nothing else. VS does not build the project with the newly edited resource file. So if I run the application again, it actually hasn't been updated to use my newly...
2
1901
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 files. My application will load the resources into memory as they are needed. I would like to be able to read and write to these embedded resources. Is it possible to write to an embedded resource within an assembly? If so, how? If it's not...
0
2207
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 multiple web forms. When you compile the application, it creates a DLL. If you view this DLL using ILDASM (the manifest), it shows info about the resources stored in the DLL. There is essentially an embedded resource "section" for each web form. The...
1
5303
by: Tom Edelbrok | last post by:
I'm reading embedded bitmaps from an EXE project and everthing works fine. I do a GetExecutingAssembly, followed by setting a stream object to MyAssemblyName.GetManifestResourceStream("MyApp.MyBitmap.BMP"). Note that the BMP is set as an embedded resource via it's properties in the VB.NET project. Finally, I do a "New Bitmap(MyStream)" to fetch the resource into a Bitmap object and job done - I can display it in a PictureBox. However,...
4
4437
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 would like them to be embedded as "RootNamespace.Folder.Filename". I see that the .resources files are embedded with the containing folder information in the namespace, and I think c# projects work this way, too. Is there any way (a vbc command...
1
1981
by: WT | last post by:
Hello, My 1.1 web site was using GetManifestResourceStream to get strategic .js files embedded as resources in the site assembly, but now it is no more allowed to embed resources by specifying a build process of embedding. ,Now we have the App_GlobalResources so how to use code like this with it : Stream st = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceID);
2
2429
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 namespace "EmbeddedResources" My resources are not included when the content is rendered in the browser. I have marked my JavaScript resource as Embedded. I am able to retrieve the path to the resource from the WebResource.axd HTTP Handler during...
0
11126
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11299
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10662
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9865
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8220
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6309
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4911
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4510
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3512
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.