MTSkull Posted September 15, 2006 Posted September 15, 2006 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. 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 Quote "Beer is proof that God loves us and wants us to be happy." -Benjamin Franklin
Administrators PlausiblyDamp Posted September 15, 2006 Administrators Posted September 15, 2006 One thing to try - if you open the assembly with ildasm and look at the manifest there should be entries that begin .mresource public try using the exact same string as is listed in the manifest and see if that works. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
MTSkull Posted September 15, 2006 Author Posted September 15, 2006 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 Quote "Beer is proof that God loves us and wants us to be happy." -Benjamin Franklin
Administrators PlausiblyDamp Posted September 15, 2006 Administrators Posted September 15, 2006 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. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
MTSkull Posted September 15, 2006 Author Posted September 15, 2006 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. Quote "Beer is proof that God loves us and wants us to be happy." -Benjamin Franklin
MTSkull Posted September 15, 2006 Author Posted September 15, 2006 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 Quote "Beer is proof that God loves us and wants us to be happy." -Benjamin Franklin
Administrators PlausiblyDamp Posted September 15, 2006 Administrators Posted September 15, 2006 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. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
MTSkull Posted September 15, 2006 Author Posted September 15, 2006 Cool Thanks a bunch MT Quote "Beer is proof that God loves us and wants us to be happy." -Benjamin Franklin
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.