Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I access another project's Embedded Resource from a different project in the same solution?

I have one xml file that stands as an embedded resource in Project_A.

And I want to reach this embedded resource from Project_B which references Project_A.

(Basically Project_B consists of unit tests and I run them with ReSharper.)

Is it possible to access embedded resource of Project_A when I am working on Project_B?

Or in general, can I access another project's Embedded Resource from a different project in the same solution?

like image 587
pencilCake Avatar asked Jul 16 '11 12:07

pencilCake


1 Answers

Yes, you can. Here is an example, how you can get the embedded resource System.Timers.Timer.bmp inside of the .NET Framework's System.dll:

using (Stream stream = typeof(System.Timers.Timer).Assembly.
                           GetManifestResourceStream("System.Timers.Timer.bmp"))
{
    using (Bitmap bitmap = new Bitmap(stream))
    {
        //bitmap.Dump();
    }
}

... or to get the list of the resource names:

string[] names = typeof(System.Timers.Timer).Assembly.GetManifestResourceNames();

... just replace typeof(System.Timers.Timer) with a type inside of the assembly containing your embedded resources.

like image 122
ulrichb Avatar answered Sep 30 '22 03:09

ulrichb