Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2011-03-16
4
Medium Priority
?
1,063 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
  • 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

926 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