Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Add an image to a dll

Posted on 2005-05-12
14
Medium Priority
?
226 Views
Last Modified: 2010-04-16
Hey all,

I have a dll component which will be used by a large number of webprojects.
This dll component contains some WebControls that will be rendered to the page, including ImageButtons.

Now, what I want is that I do not have to copy a directory containing the images for the ImageButtons to every webproject that will use my dll component.
I know that you can embed images as a resource in your project, but as far as I can tell, that only goes for Btimap objects which you can load using a stream, not for ImageButtons that will look for a path.

So in short, I want to be able to add a reference to the dll component from a webproject, and that the images for my imagebuttons will still be found.

How do I do this? Is this possible?

Thanks,

Razzie
0
Comment
Question by:Razzie_
  • 7
  • 5
  • 2
14 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 13985344
Would extracting images from an assembly, create a file, and then mapping the ImageButton's ImageURL to the temporary file be feasible?

Bob
0
 
LVL 8

Author Comment

by:Razzie_
ID: 13986535
Do you mean embedding the images as a resource and extracting / saving them at run-time? If you do, then I'm afraid not, because that would mean a performance hit, and I'm not willing to sacrifice performance for this (which is only a nuisance, but no big deal).
0
 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 600 total points
ID: 13986574
Ok, then, how about a one-time performance hit, by not using temporary files, but embed all the images within a resource DLL, and then detect if the image files exist, and if not, then create them by extracting from the DLL and saving to disk, otherwise, go on with the page?

Bob
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Expert Comment

by:BurntSky
ID: 13988588
Bob is right.  Creating the files at runtime would be the only way around it.  The HTML code ASP.NET generates will look for a static image file.  No ifs, ands or buts about it.  There has to be an image file for the ImageButton to link to.

I think the idea is nice, but I don't see that it would be difficult to copy a folder of images to whatever servers need them.  You won't be saving any file size and you definitely won't increase your performance.  It seems like compiling the images into an assembly and writing the code to extract them would take more time than it would have to just copy the whole image folder in the first place.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 13988605
Plus, the overhead of managing images, when you add/delete them.

Bo
0
 
LVL 9

Expert Comment

by:BurntSky
ID: 13988631
Maybe I shouldn't say it's impossible, but just... unreasonable.  I suppose there is probably a way to catch requests from IIS, execute some code and stream out an image file in the Http response... But I have no idea how.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 13988659
Well, you could add the image stuff to the Output stream, with a little bit of magic, of which I don't have.

Bob
0
 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 600 total points
ID: 13988677
Proof of concept:

CAPTCHA Image:
http://www.codeproject.com/aspnet/CaptchaImage.asp

Bob
0
 
LVL 9

Accepted Solution

by:
BurntSky earned 400 total points
ID: 13988848
What about something like the following; I haven't tried it, but it seems like it should work:

Assembly assembly = Assembly.Load(assemblyName);
Image image = Image.FromStream(assembly.GetManifestResourceStream(imageName));
image.Save(Response.OutputStream, ImageFormat.Gif);

Stick that in its own ASPX page (like image.aspx) and then pass in a query string with imageName.  Then reference it like so:

<img src="image.aspx?image=SomeImage.gif" />
0
 
LVL 9

Expert Comment

by:BurntSky
ID: 13988861
haha, I love how I just went from basically saying its not possible to having some code to use.
0
 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 600 total points
ID: 13988952
Transporting and Displaying Images using DIME and HTTP Handlers:
http://www.c-sharpcorner.com/Code/2004/April/DimeImageViewer.asp

Bob
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 13989012
Displaying multiple dynamic images in a WebForm:
http://www.codeproject.com/aspnet/multipledynimageswebform.asp

Bob
0
 
LVL 9

Expert Comment

by:BurntSky
ID: 13989014
Hmm... I hadn't thought about Http handlers.  I suppose you could stick that code in an ASHX file instead of an ASPX file and reduce some overhead.
0
 
LVL 8

Author Comment

by:Razzie_
ID: 14075478
Sorry for the late response, but wasn't actively working on this for the last week.

I found this article myself too http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/servingimages.asp which did have some good information also.

Thanks for all the input.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Integration Management Part 2
Suggested Courses
Course of the Month21 days, 4 hours left to enroll

810 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