Resource File Null

MTSkull

Centurion
Joined
Mar 25, 2003
Messages
151
Location
Boulder, Colorado
I used Plausably Damp's example to build this code. The example code works but mine does not. I added the files to the resource file, and can see them when I open the Resources.resx file but no matter what I try the myassembly call returns null. I have checked for case sensitivty and ensured that the names are acurate. Not sure where I am going wrong here.

C#:
        private void chkPCBOne_CheckedChanged(object sender, EventArgs e)
        {
            //access the resource file where the graphic objects are embedded
            Assembly myAssem;
            myAssem = Assembly.GetExecutingAssembly();
            
            System.IO.Stream BlueLED;
            // this next line returns Null
            BlueLED = myAssem.GetManifestResourceStream("HTPlus_BON.Images.LED_Blue.gif");
            
            System.IO.Stream SeaGreenLED;
             // this next line returns Null
            SeaGreenLED = myAssem.GetManifestResourceStream("HTPlus_BON.Images.LED_Seagreen.gif");
            
            Image TempImage;

            if (chkPCBOne.Checked == true)
                TempImage = new Bitmap(SeaGreenLED);
            else
                TempImage = new Bitmap(BlueLED);
 
            led_One.Image = TempImage;
            CheckBoxIntegrity();
        }

Thanks
MT
 
One thing to try - if you open the assembly with ildasm and look at the manifest there should be entries that begin
Code:
.mresource public <name of resource>

try using the exact same string as is listed in the manifest and see if that works.
 
PlausiblyDamp said:
One thing to try - if you open the assembly with ildasm and look at the manifest there should be entries that begin

Must confess my ignorance here. I searched help for ildasm and found that it is also called MSIL Disassembler. I can not for the life of me figure out how to get to it to use it. I searched for the file on my hard drive and it came back with nothing. I am using .net 2005 Standard

MT
 
If you look under the Visual Studio group on your start menu there should be a sub menu called 'Visual Studio Tools' or similar - inside there there should be a 'Visual Studio Command Prompt' - run that and then type ildasm and it should work.

If it isn't present then you might need to install the SDK tools either from the original VS CD / DVD or from the MS website.
 
My files are not listed there?

If I go to myAssembly.properties.resources they are listed there as bitmap objects and they have Gets ex: get_LED_Blue.... {Long Pause while I sniff around this cool new program}

If I type in "Properties.Resources." it exposes my resources. Will this work as well? I am going to give it a try.
 
C#:
            Image TempImage;

            if (chkPCBOne.Checked == true)
                TempImage = Properties.Resources.LED_Seagreen;
            else
                TempImage = Properties.Resources.LED_Blue;

            led_One.Image = TempImage;

This works. Is there a reason I should do it the other way?

Thanks
MT
 
If you are using VS 2005 it does this in a different way - it creates a wrapper class around the resources and makes it far easier to use.

Do it the way you are via the Properties class, much simpler.
 
Back
Top