Load resource from DLL

  • Thread starter Thread starter Yoavo
  • Start date Start date
Y

Yoavo

Hi,
In my application I need to load a bitmap which exists on an external DLL.
How do I do it ?

Yoav.
 
This assumes the "external dll" is a managed assembly named
"AssemblyResources.dll". The code shown uses the GetManifestResourceNames
method to load the first resource, convert to Bitmap, and display in a
Picturebox:

Assembly asm = Assembly.LoadFrom(System.Environment.CurrentDirectory +
@"\AssemblyResources.dll");
Stream strm =
asm.GetManifestResourceStream((string)asm.GetManifestResourceNames()[0]);
Bitmap b = (Bitmap)Image.FromStream(strm);
pictureBox1.Image = b;


-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
 
The external DLL is unmanaged DLL.

Peter Bromberg said:
This assumes the "external dll" is a managed assembly named
"AssemblyResources.dll". The code shown uses the GetManifestResourceNames
method to load the first resource, convert to Bitmap, and display in a
Picturebox:

Assembly asm = Assembly.LoadFrom(System.Environment.CurrentDirectory +
@"\AssemblyResources.dll");
Stream strm =
asm.GetManifestResourceStream((string)asm.GetManifestResourceNames()[0]);
Bitmap b = (Bitmap)Image.FromStream(strm);
pictureBox1.Image = b;


-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net




Yoavo said:
Hi,
In my application I need to load a bitmap which exists on an external
DLL.
How do I do it ?

Yoav.
 
Back
Top