Parser Error Message: The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
On the link in my config where I add the handler
<add verb="GET" type="MY.RNET.ImageHandler
Main Topics
Browse All TopicsI am getting a web.config file error in sharepoint trying to add an ihttphandler
I also added to my safecontrols
<SafeControl Assembly="MY.RNET.ImageHan
<httpHandlers>
<remove verb="GET,HEAD,POST" path="*" />
<add verb="GET" type="MY.RNET.ImageHandler
<add verb="GET,HEAD,POST" path="*" type="Microsoft.SharePoint
Here is my code
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls.
using System.Web.UI.HtmlControls
using System.Net.Mime;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
namespace MY.RNET.ImageHandler
{
class ImageHandler : IHttpHandler
{
public ImageHandler()
{
}
public string GetContentType(String path)
{
switch (Path.GetExtension(path))
{
case ".bmp": return "Image/bmp";
case ".gif": return "Image/gif";
case ".jpg": return "Image/jpeg";
case ".png": return "Image/png";
default: break;
}
return String.Empty;
}
public ImageFormat GetImageFormat(String path)
{
switch (Path.GetExtension(path).T
{
case ".bmp": return ImageFormat.Bmp;
case ".gif": return ImageFormat.Gif;
case ".jpg": return ImageFormat.Jpeg;
case ".png": return ImageFormat.Png;
default: return null;
}
}
protected byte[] WatermarkImage(HttpContext
{
byte[] imageBytes = null;
if (File.Exists(context.Reque
{
// Normally you'd put this in a config file somewhere.
string watermark = "John Doe - © EXAMPLE Company 2007";
Image image = Image.FromFile(context.Req
Graphics graphic;
if (image.PixelFormat != PixelFormat.Indexed && image.PixelFormat != PixelFormat.Format8bppInde
{
// Graphic is not a Indexed (GIF) image
graphic = Graphics.FromImage(image);
}
else
{
/* Cannot create a graphics object from an indexed (GIF) image.
* So we're going to copy the image into a new bitmap so
* we can work with it. */
Bitmap indexedImage = new Bitmap(image);
graphic = Graphics.FromImage(indexed
// Draw the contents of the original bitmap onto the new bitmap.
graphic.DrawImage(image, 0, 0, image.Width, image.Height);
image = indexedImage;
}
graphic.SmoothingMode = SmoothingMode.AntiAlias & SmoothingMode.HighQuality;
Font myFont = new Font("Arial", 15);
SolidBrush brush = new SolidBrush(Color.FromArgb(
/* This gets the size of the graphic so we can determine
* the loop counts and placement of the watermarked text. */
SizeF textSize = graphic.MeasureString(wate
// Write the text across the image.
for (int y = 0; y < image.Height; y++)
{
for (int x = 0; x < image.Width; x++)
{
PointF pointF = new PointF(x, y);
graphic.DrawString(waterma
x += Convert.ToInt32(textSize.W
}
y += Convert.ToInt32(textSize.H
}
using (MemoryStream memoryStream = new MemoryStream())
{
image.Save(memoryStream, GetImageFormat(context.Req
imageBytes = memoryStream.ToArray();
}
}
return imageBytes;
}
#region IHttpHandler Members
public bool IsReusable
{
get { return false; }
}
public void ProcessRequest(HttpContext
{
context.Response.Clear();
context.Response.ContentTy
byte[] imageBytes = WatermarkImage(context);
if (imageBytes != null)
{
context.Response.OutputStr
}
else
{
// No bytes = no image which equals NO FILE. :)
// Therefore send a 404 - not found response.
context.Response.StatusCod
}
context.Response.End();
}
#endregion
}
}
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: deepaknetPosted on 2009-04-14 at 02:33:03ID: 24136276
What is the error that you are getting?