12 Feb 2009 @ 1:24 AM 
 

Embed images in dll’s using visual studio 2005

 


1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...
1,043 views

In short you need to do a few things to make it possible to embed images into a dll file.
(c#)

1) add an image to your (web) project
2) select the image and go to property -> “Build Action” and choose “Embedded Resource”
3) add this in your AssemblyInfo.cs “[assembly: System.Web.UI.WebResource("namespace.directory.imageName.png", "img/png")]“
4) in your *.cs file add this to show the image: Image1.ImageUrl = Page.ClientScript.GetWebResourceUrl(typeof(_Default), “namespace.directory.imageName.png”);
5) press f5, if there are no errors test the project using your webbrowser (localhost:yourPortNumber)

Download my project files here

// for my own reference only

old

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

<html xmlns=”http://www.w3.org/1999/xhtml” >
<head><title>
Untitled Page
</title></head>
<body>

<form name=”form1″ method=”post” action=”default.aspx” id=”form1″>
<div>
<input type=”hidden” name=”__VIEWSTATE” id=”__VIEWSTATE” value=”/wEPDwUKMTk3MzY5NzU2Ng9kFgICAw9kFgICAQ8PFgIeCEltYWdlVXJsBX8vV2ViUmVzb3VyY2UuYXhkP2Q9TkxVeWFfSy1NeVVUdFhQRlRFLUlSZmNVNXZxY0Nya2dNRUxiY2IweE1YTGl6Y3NKWlpOVk95MDM3b3U5Q2VkcUhYSXV0OHFqSUo5Z04zYWpWUHlzancyJnQ9NjMzNjk5OTQ4NjI4MTI1MDAwZGRkGJdrne5DaxGKDYKjEM9W2u2rKA4=” />
</div>

<div>
<img id=”Image1″ src=”/WebResource.axd?d=NLUya_K-MyUTtXPFTE-IRfcU5vqcCrkgMELbcb0xMXLizcsJZZNVOy037ou9CedqHXIut8qjIJ9gN3ajVPysjw2&amp;t=633699948628125000″ style=”height:133px;width:186px;border-width:0px;” />

</div>
</form>
</body>
</html>

New

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

<html xmlns=”http://www.w3.org/1999/xhtml” >
<head><title>
Untitled Page
</title></head>
<body>
<form name=”form1″ method=”post” action=”default.aspx” id=”form1″>
<div>
<input type=”hidden” name=”__VIEWSTATE” id=”__VIEWSTATE” value=”/wEPDwUJMzk2MDQzMjE5ZGR7dTPBGX1u66LJZkHGMPuuDzWCqQ==” />
</div>

<div>

<input type=”hidden” name=”__EVENTVALIDATION” id=”__EVENTVALIDATION” value=”/wEWAwK978qBBALs0bLrBgKM54rGBl3Zfy1DAPCuPQn4rUg4hT3m1tl0″ />

</div>
<div>
&nbsp;<span id=”Label2″>Type a number higher than 1000 and lower than 100000</span><br />
&nbsp;<input name=”TextBox1″ type=”text” id=”TextBox1″ />
<input type=”submit” name=”Button1″ value=”Button” id=”Button1″ />
<img id=”Image1″ src=”" style=”border-width:0px;” />
<span id=”Label1″></span><br />
<br />
&nbsp;

</div>
</form>
</body>
</html>

Related posts

Your Ad Here
Tags Tags: ,
Categories: .Net
Posted By: HappyFace
Last Edit: 12 Feb 2009 @ 01 24 AM

EmailPermalink
 

Responses to this post » (None)

 

Post a Comment

You must be logged in to post a comment.

\/ More Options ...
Change Theme...
  • Users » 888
  • Posts/Pages » 1,444
  • Comments » 506
Change Theme...
  • VoidVoid « Default
  • LifeLife
  • EarthEarth
  • WindWind
  • WaterWater
  • FireFire
  • LightLight

Online Users



    No Child Pages.

Forum



    No Child Pages.