Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-03-16
4
Medium Priority
?
1,045 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
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, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

670 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