Accessing GIF from Embedded Resource

Hi all,

I am getting a NULL exception from the following code....

Assembly asm = Assembly.GetExecutingAssembly();
Bitmap backgroundImage = new Bitmap(asm.GetManifestResourceStream("bg.gif"));

Is it because I am putting a GIF into a Bitmap If so, how do I extract a GIF from an embedded resource

Tryst





Answer this question

Accessing GIF from Embedded Resource

  • Phil Robert

    embedded resources as I said AFAIK, when you embed it, it starts with the namespace.filename.ext

    even if your filename is "test.bmp", it will embed it as namespace.test.bmp. At least you have it sorted now :-)



  • CodePfo

    huh

    generally AFAIK or from my experience, the embedded resource is called by the namespace (product name) + "." + the filename. Does this not work at all



  • barkingdog

    Hi, and thanks for the reply.

    I just tested it, and it seems to use the default Namespace value you specify in the Solution properties, and not the Product Name.


  • Mantorok

    Ok, ignore me, I just had the URL/pathname of the embedded resource wrong, thats all. For some reason the embedded resource was prefixed with the Solution name. It doesn't normally do this, does it

    Tryst


  • Docpro777

    it should be this...try this:

    Assembly asm = Assembly.GetExecutingAssembly();
    Bitmap backgroundImage = new Bitmap(asm.GetManifestResourceStream(Application.ProductName + ".bg.gif"));

    also, the filenames are case sensitive



  • kperson

    When you said Product Name, I thought you meant the value that you provide in the assembly.cs file. It does use the default namespace and the file name itself, like you have put it, namespace.filename.filetype.


  • Accessing GIF from Embedded Resource