Solved

null value in System.Reflection.Assembly.GetExecutingAssembly().GetFile

Posted on 2011-03-16
4
1,012 Views
Last Modified: 2012-05-11
Hi Experts,

I have this problem:
I created a new project and I added two embedded picture files to it.
But when I call System.Reflection.Assembly.GetExecutingAssembly().GetFile("lock_closed.jpg")
I've got a null value returning from the GetFile method.
0
Comment
Question by:dionisio_79
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 35152094
Try it without the extension:
System.Reflection.Assembly.GetExecutingAssembly().GetFile("lock_closed")

Open in new window

0
 

Author Comment

by:dionisio_79
ID: 35152570
i've tried without extension but it doesn't work
0
 

Accepted Solution

by:
dionisio_79 earned 0 total points
ID: 35152577
Here's a complete sample:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            System.Reflection.Assembly myAssembly = System.Reflection.Assembly.GetExecutingAssembly();
            Stream myStream = myAssembly.GetManifestResourceStream("christmas");
            this.button1.Image = Image.FromStream(myStream);



        }
    }
}
0
 

Author Closing Comment

by:dionisio_79
ID: 35304175
my files where under a subfolder thatìs why it didn't work
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question