Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 936511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:19:33+00:00 2026-05-15T21:19:33+00:00

I have a controls library which I’ve added a .resx file to (ImageResources.resx). It

  • 0

I have a controls library which I’ve added a .resx file to (ImageResources.resx). It contains two .png images which I subsequently added.

In that same library I have a control which loads a couple of images to do some custom drawing, but I don’t seem to be able to load the resources:

void GTableLayoutPanel::SetBorderImagesFromManifest(String^ topLeftCornerImageName, String^ topImageName)
{
    // Grab the assembly this is being called from
    Assembly^ assembly = Assembly::GetExecutingAssembly();

    // Grab the images from the assembly
    Stream^ stream = assembly->GetManifestResourceStream(topLeftCornerImageName);
    Image^ topLeftImage = System::Drawing::Image::FromStream(stream);
    stream = assembly->GetManifestResourceStream(topImageName);
    Image^ topImage = System::Drawing::Image::FromStream(stream);

    // Update the internal store from the supplied images
    SetBorderImages(topLeftImage, topImage);
}

…gives me errors complaining that stream is null which suggests my call to GetManifestResourceStream is failing.

The images are called group_box_top.png and group_box_top_left.png and I’m calling the image loader as follows:

SetBorderImagesFromManifest("group_box_top_left.png", "group_box_top.png");

I’ve also tried:

SetBorderImagesFromManifest("group_box_top_left", "group_box_top");

…because the files appear in the .resx file without the .png extensions, but this gives the same error.

Have I missed a step here?

[Edit] I tried the suggestion in that final link and I get:

MyControlsLib.ImageResources.resources

So now I’ve tried referencing:

Stream^ strm1 = assembly->GetManifestResourceStream("MyControlsLib.ImageResources.resources.group_box_top_left");
Stream^ strm2 = assembly->GetManifestResourceStream("MyControlsLib.ImageResources.resources.group_box_top_left.png");
Stream^ strm3 = assembly->GetManifestResourceStream("MyControlsLib.ImageResources.group_box_top_left");
Stream^ strm4 = assembly->GetManifestResourceStream("MyControlsLib.ImageResources.group_box_top_left.png");

…all of which return nullptr :-/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T21:19:34+00:00Added an answer on May 15, 2026 at 9:19 pm

    I finally got the magic combination for a C++/CLI solution. So just in case anyone else has this issue:

    Method 1 (via .resx file)

    1. Add the image files (I used .pngs, but bitmaps etc. work too).
    2. Add a resource file:
      1. Go to Solution Explorer.
      2. Right-click on Resource Files in the project you’re adding to
      3. Select Add > New Item..
      4. Choose Visual C++ > Resource > Assembly Resource File (.resx). I nameed mine “ImageResources.resx”
    3. Add the images:
      1. Double click on “ImageResources.resx” in Solution Explorer
      2. Click on the Add Resource button and select Add Existing File...
      3. Select the images you want to embed. I added group_box_top.png and group_box_top_left.png which appear in the .resx file as group_box_top and group_box_top_left.

    You can then grab the images from the manifest with:

    // Grab the assembly this is being called from
    Assembly^ assembly = Assembly::GetExecutingAssembly();
    AssemblyName^ assemblyName = assembly->GetName();
    
    // Grab the images from the assembly
    ResourceManager^ rm = gcnew ResourceManager(assemblyName->Name+".ImageResources", assembly);
    Bitmap^ topLeftImage = (Bitmap^)rm->GetObject("group_box_top_left");
    Bitmap^ topImage = (Bitmap^)rm->GetObject("group_box_top");
    

    Note that the ImageResources string passed into the ResourceManager constructor must match the name of your .resx file.

    Method 2 (via linker)

    1. Add the files:
      1. Right-click on your project
      2. Go to Linker -> Input
      3. Add the files you want to embed to the Embed Managed Resource File property. I added PingSend.wav here.

    To get access to the files simply do:

    System::Reflection::Assembly^ assembly = Assembly::GetExecutingAssembly();
    System::Media::Sonudplayer^ pingPlayer = gcnew System::Media::SoundPlayer(assembly->GetManifestResourceStream("PingSend.wav"));
    

    ..which in this case, loads the audio file ready to play back.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.