Solved

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

Posted on 2011-03-16
4
1,025 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

624 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