GetManifestResourceStream stream question

T

Tom Edelbrok

I'm reading embedded bitmaps from an EXE project and everthing works fine. I
do a GetExecutingAssembly, followed by setting a stream object to
MyAssemblyName.GetManifestResourceStream("MyApp.MyBitmap.BMP"). Note that
the BMP is set as an embedded resource via it's properties in the VB.NET
project. Finally, I do a "New Bitmap(MyStream)" to fetch the resource into a
Bitmap object and job done - I can display it in a PictureBox.

However, when I add the same bmp into a DLL (ie: a Class Library project)
instead of an EXE project, it doesn't work. When I set the stream object to
MyAssemblyName.GetManifestResourceStream("MyDllName.MyBitmap.BMP") the
stream is returned as "nothing". I'm sure my embedded resource path is
correct because I use "ILDASM.EXE" to check out the DLL assemblies manifest,
and the path shows as public mydllname.MyBitmap.BMP.

So what am I doing wrong? Is it not permitted to read embedded resources
from a DLL? Or am I missing a step when dealing with DLL's? All I get is an
exception loading the bitmap because the stream is "nothing".

Thanks for help,

Tom Edelbrok
 
T

Tom Edelbrok

Figured it out!

When you have an EXE project open simultaneous with a DLL (Class Library)
project VB.NET will permit you to flip back and forth between the two very
easily. You can even make changes in the DLL code while in the EXE project
and do debugging.

BUT DON'T!!!

Because the code changes you make don't always apply. To be certain that
they are applied you must always go back to the DLL project, rebuild it,
then go back to your EXE project and run.

Therefore the coding changes I made to fix my Embedded Resource problem
weren't being applied. In fact, my coding changes were correct but I didn't
know it.

Tom
 
J

Jay B. Harlow [MVP - Outlook]

Tom,
Did you reference the Project or the DLL in the EXE project?

When I have an Application (EXE) & Class Library (DLL) project in the same
solution I always reference the Class Library Project in the Application
Project. VS.NET then sets up the correct dependencies & rebuilds both as
needed to ensure every thing works as needed!

If you reference the DLL itself in the Application project, the VS.NET
doesn't know what the dependencies are & you need to manually set them via
'Project - Project Dependencies'

Hope this helps
Jay

| Figured it out!
|
| When you have an EXE project open simultaneous with a DLL (Class Library)
| project VB.NET will permit you to flip back and forth between the two very
| easily. You can even make changes in the DLL code while in the EXE project
| and do debugging.
|
| BUT DON'T!!!
|
| Because the code changes you make don't always apply. To be certain that
| they are applied you must always go back to the DLL project, rebuild it,
| then go back to your EXE project and run.
|
| Therefore the coding changes I made to fix my Embedded Resource problem
| weren't being applied. In fact, my coding changes were correct but I
didn't
| know it.
|
| Tom
|
|
|
| | > I'm reading embedded bitmaps from an EXE project and everthing works
fine.
| > I do a GetExecutingAssembly, followed by setting a stream object to
| > MyAssemblyName.GetManifestResourceStream("MyApp.MyBitmap.BMP"). Note
that
| > the BMP is set as an embedded resource via it's properties in the VB.NET
| > project. Finally, I do a "New Bitmap(MyStream)" to fetch the resource
into
| > a Bitmap object and job done - I can display it in a PictureBox.
| >
| > However, when I add the same bmp into a DLL (ie: a Class Library
project)
| > instead of an EXE project, it doesn't work. When I set the stream object
| > to MyAssemblyName.GetManifestResourceStream("MyDllName.MyBitmap.BMP")
the
| > stream is returned as "nothing". I'm sure my embedded resource path is
| > correct because I use "ILDASM.EXE" to check out the DLL assemblies
| > manifest, and the path shows as public mydllname.MyBitmap.BMP.
| >
| > So what am I doing wrong? Is it not permitted to read embedded resources
| > from a DLL? Or am I missing a step when dealing with DLL's? All I get is
| > an exception loading the bitmap because the stream is "nothing".
| >
| > Thanks for help,
| >
| > Tom Edelbrok
| >
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top