Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › C# .ico file not found
New Posts  All Forums:Forum Nav:

C# .ico file not found

post #1 of 2
Thread Starter 
So I just started using C#

my program runs when running directly from VS 2010, but the standalone executable throws this exception:


ArgumentNullException was unhandled

I've tried many hours to fix the problem to no avail...I've placed the ico file in the resources folder, set the build action to embedded resource.
Code:
_assembly = Assembly.GetExecutingAssembly();
_imageStream = _assembly.GetManifestResourceStream("MathMunchersTheGame.muncher.ico");
_textStreamReader = new StreamReader(_assembly.GetManifestResourceStream("MathMunchersTheGame.muncher.ico"));


It is either my naming convention or the ico file itself



Source: http://support.microsoft.com/kb/319292
Black Silence
(15 items)
 
  
CPUMotherboardRAMHard Drive
i5 3570k @ 4.5 GHz Asus P8Z77-M Pro Kingston HyperX Genesis 8 GB - 1600 MHz Seagate Barracuda 250 GB 
Optical DriveCoolingOSMonitor
Samsung WriteMaster Noctua NH-D14 Windows 8 Samsung S23A700D 120Hz 
KeyboardPowerCaseMouse
Logitech Navigator Enermax Infiniti 650W Fractal R3 Black Pearl Razer Death Adder 
Mouse PadAudio
SteelSeries QcK Mass Altec Lansing FX4021 
  hide details  
Reply
Black Silence
(15 items)
 
  
CPUMotherboardRAMHard Drive
i5 3570k @ 4.5 GHz Asus P8Z77-M Pro Kingston HyperX Genesis 8 GB - 1600 MHz Seagate Barracuda 250 GB 
Optical DriveCoolingOSMonitor
Samsung WriteMaster Noctua NH-D14 Windows 8 Samsung S23A700D 120Hz 
KeyboardPowerCaseMouse
Logitech Navigator Enermax Infiniti 650W Fractal R3 Black Pearl Razer Death Adder 
Mouse PadAudio
SteelSeries QcK Mass Altec Lansing FX4021 
  hide details  
Reply
post #2 of 2
Thread Starter 
I solved it, I'll leave this up here for future reference for anyone
Code:
Assembly targetAssembly = Assembly.GetExecutingAssembly();
Icon icon = new Icon(targetAssembly.GetManifestResourceStream("MathMunchersTheGame.Resources.mm.ico"));


remember to put   using System.Reflection; up top

Got my 2d game working, now just have to put in some sound.
Black Silence
(15 items)
 
  
CPUMotherboardRAMHard Drive
i5 3570k @ 4.5 GHz Asus P8Z77-M Pro Kingston HyperX Genesis 8 GB - 1600 MHz Seagate Barracuda 250 GB 
Optical DriveCoolingOSMonitor
Samsung WriteMaster Noctua NH-D14 Windows 8 Samsung S23A700D 120Hz 
KeyboardPowerCaseMouse
Logitech Navigator Enermax Infiniti 650W Fractal R3 Black Pearl Razer Death Adder 
Mouse PadAudio
SteelSeries QcK Mass Altec Lansing FX4021 
  hide details  
Reply
Black Silence
(15 items)
 
  
CPUMotherboardRAMHard Drive
i5 3570k @ 4.5 GHz Asus P8Z77-M Pro Kingston HyperX Genesis 8 GB - 1600 MHz Seagate Barracuda 250 GB 
Optical DriveCoolingOSMonitor
Samsung WriteMaster Noctua NH-D14 Windows 8 Samsung S23A700D 120Hz 
KeyboardPowerCaseMouse
Logitech Navigator Enermax Infiniti 650W Fractal R3 Black Pearl Razer Death Adder 
Mouse PadAudio
SteelSeries QcK Mass Altec Lansing FX4021 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › C# .ico file not found