Sunday, May 31, 2009

How to convert Image to Thumbnail image in C#?

//value is the fullsize image byte array
_fullLectureImage = (byte[])value;

System.Drawing.Image htmlImage = ByteArrayToImage(_fullLectureImage);
System.Drawing.Image thumnailImage = htmlImage.GetThumbnailImage(_imageWidth, _imageHeight, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);
this.Page.Session[_thumbnailImage] = ImageToByteArray(thumnailImage);


///
/// Returns System.Drawing.Image from byte array.
///

/// array of byte
/// System.Drawing.Image
private static System.Drawing.Image ByteArrayToImage(byte[] byteArrayIn)
{
MemoryStream memoryStream = new MemoryStream(byteArrayIn);
System.Drawing.Image returnImage = System.Drawing.Image.FromStream(memoryStream);
return returnImage;
}

///
/// Returns byte array from System.Drawing.Image.
///

/// System.Drawing.Image
/// array of byte
private static byte[] ImageToByteArray(System.Drawing.Image imageIn)
{
MemoryStream memoryStream = new MemoryStream();
imageIn.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Jpeg);
return memoryStream.ToArray();
}

Wednesday, May 27, 2009

How to deploy web service on SharePoint site?

1. Create .asmx file and mark it as strong name.
2. Put the DLL into GAC.
3. Put .asmx file into LAYOUTS folder
4. Open the .asmx in notepad, remove the CodeBehind attribute and modify the class attributes as below
Class=", , Version=, Culture=, PublicKeyToken="
5. Run disco command from command prompt and we will get .disco and .wsdl files
6. Copy all the 3 files (asmx, .disco and .wsdl) to ISAPI folder.
7. Rename the .disco and .wsdl files to .aspx files. e.g. Rename the EMBS.disco to EBMSdisco.aspx
8. Access the url as
:/_vti_bin/.asmx">http://:/_vti_bin/.asmx
How to create .msi of WebApplication or WebSite and How to deploy it in IIS ?

1. Open the Web application project that you want to deploy.
2. Create New Project from select “Setup and Deployment Projects” à Web Set Up project. That will added Web Set Up project in same solution.
3. Select Web Application Folder in the left pane of the File System window.
4. Then,from the File menu select Add -> Existing Website to open the Add Existing WebSite Dialog box.Choose the Web Application that you want to Deploy.
5. Then right click on the “Web Application Folder” in the left pane of the File System window, and click add à Project Output menu, that will open dialog “Add project Output group”, then select content Files and click ok.
6. Then build the solution. That will create the .msi in the Debug directory of the Web Setup project.
7. Run the .mis file on any server to Deploy your WebSite or WebApplication.
How to convert website to webapplication in .NET?

Consider you have Solution and website is exist in that solution then
1. Added WebApplication project in existing solution. (That you have one website and one WebApplication in that solution)
2. Copy all files from website to webApplication with keep same structure as website.
3. Then right click on the webApplication and click on “Convert to Web Application“. That will add .designer.cs file for all .aspx pages and ascx pages.
4. Add namespace to all .aspx and .ascx files. (namespace will add in .aspx file in Inherits attribute of page dirsctive, .aspx.cs and .designer.cs file)
5. Then delete website from that solution.

And your webApplication will created.