Question How to retirve image from dll?

elrevathy

New member
Joined
Dec 23, 2011
Messages
3
Programming Experience
1-3
Hi...

I want to show an image in my project... Now it available in setup folder... In code I am retrieving that image via path.. But my need is, I won't put that image in setup folder... Rather than that, I have to create a dll file that contains my image.. Using that dll in my project I have to retrieve the image.. How can I create that dll and How can I use that dll to retrieve the image in my code?

Can anyone help for my need?

Thanks in advance...
 
It may be easier to just create a regular Class Library project, add the image to project resources, and set access modifier for project resources to Public. The default empty class Class1 can be removed.

You can add the project to your application solution and add a project reference to it, or compile it separately and add reference to the dll.
After that the image can be retrieved using the generated and strongly typed resource property, eg:
Me.Image = ClassLibraryNamespace.My.Resources.imageResourceName
 
Thank you so much john...

your reply helped me lot... Is there any way to access image which is available in solution explorer (Available Directly.. not in Resources) to the picturebox control without mentioning the application path?

I added one image to the solution explorer by Add--> Existing Item --> RequiredImage.bmp... Now I want to show this image in my PictureBox1 control... For this, Is there any way to retrieve this image without mentioning the Application.StartupPath\\...?

Thanks in advance....
 
That depends on the items Build Action/Copy mode, for example Content/Copy copies the file to output and it must be accessed by file path. If set as EmbeddedResource it is added to assembly resources and can be retrieved with Assembly.GetManifestResourceStream method, but better then to add it to project resources and use the My.Resources object.
 
Back
Top