Solved

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

Posted on 2011-03-16
4
967 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 74

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
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!
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

758 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now