CS0104: 'Image' is an ambiguous reference between 'System.Web.UI.WebControls.Image' and 'System.Drawing.Image'

 CS0104: 'Image' is an ambiguous reference between 'System.Web.UI.WebControls.Image' and 'System.Drawing.Image'


<%@ Page Language="C#" %>

<%@ Import Namespace="System.Drawing" %>

<%@Import Namespace="System.Drawing.Imaging" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
script type="text/C#" runat="server">

void Page_Load() {
//The @ means "Ignore escape characters!" in the following string. It is a verbatim
//literal string - any backslashes (and newlines) in the string are not treated as
//escape characters or real line terminators.
//FileInfo f = new FileInfo( @"C:\Test.txt" );
//FileInfo f = new FileInfo("C:\\Test.txt");

string WorkingDirectory = @"C:\Test";
Image imgPhotoVert = Image.FromFile(WorkingDirectory + @"\JillandBen.jpg");
Image imgPhoto = null;
imgPhoto = FixedSize(imgPhotoVert, 300, 300);
imgPhoto.Save(WorkingDirectory +
@"\newJIllandBen.jpg", ImageFormat.Jpeg);

static System.Drawing.Image FixedSize(Image imgPhoto, int Width, int Height){   --ERROR PART
int sourceWidth = imgPhoto.Width;
int sourceHeight = imgPhoto.Height;
int sourceX = 0;
int sourceY = 0;
int destX = 0;
int destY = 0;

3/24/2006 4:18:53 PM
asp.net.getting-started 91979 articles. 4 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 0
Get it on Google Play
Get it on Apple App Store

The compiler doe snot know which base object to use to create an instance of your controls. This happens because one of your import statements called 'System.Drawing' that has an Image child object, just like 'System.Web.UI.WebControls' So use a fully qualified namespace reference.

Do you know the truth when you hear it?
3/24/2006 4:48:01 PM

The error tells you exactly what is wrong, and leads you to the path to fix it, which is to tell the application what "Image" class to use, so

static System.Drawing.Image FixedSize(System.Drawing.Image imgPhoto, int Width, int Height){   --ERROR PART

"If you make it idiot proof, they'll build a better idiot"
3/24/2006 4:48:39 PM

prefix your Image references with the full namespace as the compiler has no way to know which Image type you mean.

you either want:





Mike Banavige

Need a site code sample in a different language? Try converting it with: http://converter.telerik.com/
3/24/2006 4:48:54 PM

Similar Artilces:

'Image' is an ambiguous reference between 'System.Web.UI.WebControls.Image' and 'System.Drawing.Image'
In my aspx page, I have the following snippet: <%@ Page Language="C#" %><%@ Import Namespace="System.IO" %><%@ Import Namespace="System.Drawing" %>     public System.Drawing.Image Test()    {      ...    }  I keep getting the 'Image' is an ambiguous reference between 'System.Web.UI.WebControls.Image' and 'System.Drawing.Image' error in my Test function (which returns an Image). How do I fix this? Right which is possible; use the full...

Converting 'System.Drawing.Image' to 'System.Web.UI.WebControls.Image'
Hello,I have an image stored on disk, that I am manipulating using the Drawing classes, and creating a 300x400 thumbnail from. Then, I want to display this image in an Image control on my webpage. How do I do that?Code:                    //Create the delegate                    System.Drawing.Image.GetThumbnailImageAbort dummyCallBack;           &nbs...

'Click' is not an event of 'System.Web.UI.WebControls.Image'
Hi, I have an imagebutton named pbx in asp page. My Codes: AddHandler pbx.Click, AddressOf Me.pbx_onClick Public Sub pbx_onClick(ByVal sender As Object, ByVal e As Web.UI.ImageClickEventArgs)         a few code line......... End Sub when i try to publish to site ,i get an error : 'Click' is not an event of 'System.Web.UI.WebControls.Image' How can I solve this problem? I'm not a VB guy, but try adding "Handles pbx.Click" to the end of your second line Public Sub pbx_onClick(ByVal sender As Object, ByV...

Name: haznen Email: haznenatyahoodotcom Product: Gran Paradiso Alpha 8 Summary: '''''''''''''''''''' Comments: '''''''''''''''''''''''''''''''''''' Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20061204 UGES/ GranParadiso/3.0a1 From URL: http://www.mozilla.org/projects/granparadiso/ Note to readers: Hendrix gives...

'Out of memory' / 'Parameter is not valid' at 'System.Drawing.Image' load
 Hi,   i have a problem with loading images. what is interesting the same type of images, the same directories some of them are loading some - not. The image size doesn't matter. It happens on a big sized and on a small sized image. So..   int id = Int32.Parse(Request.Params["id"].ToString());string sImage = "";Response.Clear();Response.ContentType = "image/JPEG";Response.Expires = 0;Response.Buffer = true;Response.Clear();sImage = GetMarkImagePath(id);FileStream fs = new FileStream(sImage, FileMode.Open, FileAccess.Read);// the foll...

Name: mario Email: ramar17atfastwebnetdotit Product: Gran Paradiso Alpha 2 Summary: ''''' Comments: K: Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a2) Gecko/20070206 GranParadiso/3.0a2 ...

Error Serializing Value 'System.Web.UI.WebCOntrols.TreeNode' of type 'System.Web.UI.WebCOntrols.TreeNode'
Hi, I am  getting the error stated in the subject when i am storing a TreeNode in a ViewState and then using it as follows if (ViewState["ProductCounty"]!=null) { TreeNode _productCountyNode = DataTree.FindNode(((TreeNode)ViewState["ProductCounty"]).ValuePath); _productCountyNode.Expand(); } what could be causing this error? Hi, I believe TreeNode isn't serializable in a way its required for objects which can be put to ViewState - as reference - (TreeNode implements IStateManager and is meant to work together with TreeView itself saving it...

Unable to cast object of type 'System.Web.UI.WebControls.FormView' to type 'System.Web.UI.WebControls.DropDownList'.
Hi,  I have a formview with a dropdownlist created dynamically. i want to determine whether the dropdownlist was clicked. the code is written in the FormView1_DataBound method. I get the following error in the line below that is in italics and underlined: Unable to cast object of type 'System.Web.UI.WebControls.FormView' to type 'System.Web.UI.WebControls.DropDownList'.   Here is my code: ddl_iFullname = New DropDownList ddl_iFullname.ID = "ddl_iFullname" ddl_iFullname.DataSource = ObjectDataSource3 ddl_iFullname.DataTextField = "fullname" ddl_iFullname.DataValueField = "...

Unable to cast object of type 'System.Web.UI.WebControls.Label' to type 'System.Web.UI.WebControls.TextBox'
I am attempting to "Update" a field in a Datagrid, but no matter what I do (Using either Label or Text Boxes)  I keep getting the same error: Unable to cast object of type 'System.Web.UI.WebControls.Label' to type 'System.Web.UI.WebControls.TextBox' The Error is highlighted below in the Sub... <==THE FIELD THAT CALLS THE ERROR  Any help would be greatly appreciated !!! Thanks !!   The code is as follows... <table border=0 height=210 bordercolor=olive ><tr valign=top><td> <asp:datagrid id="FacilityDataGrid"...

Error: Cannot convert type 'System.Web.UI.Control' to 'System.Web.UI.WebControls.ButtonField'
Hello, I am getting the following error during compiliation. Any suggestions to fix it. Thanks. Cannot convert type 'System.Web.UI.Control' to 'System.Web.UI.WebControls.ButtonField' protected void gvEvents_RowCommand(Object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Select") { int index = Convert.ToInt32(e.CommandArgument); GridViewRow selectedRow = gvEvents.Rows[index]; string sID; ButtonField btn; if (selectedRow.RowType == DataControlRowType.DataRow) { sID = ((ButtonField)selectedRow.FindControl("ID")).DataTextFi...

'System.Web.UI.WebControls.DataListItem.DataItem' is a 'property' but is used like a 'method'
 HI I have a datalist with OnItemDataBoundI get the following error when I try to get the DataItem 'System.Web.UI.WebControls.DataListItem.DataItem' is a 'property' but is used like a 'method' , any idea what's wrong with the line ?  public void Item_Bound(object sender, DataListItemEventArgs e)    {        Label originalPriceLabel;        if (e.Item.ItemType == ListItemType.Item | e.Item.ItemType == ListItemType.AlternatingItem)        {    &n...

Operator '&' is not defined for types 'String' and 'System.Web.UI.WebControls.TextBox'
Can anyone tell me what this error message means, and what to do to correct it.  Here is the code that has the error:  Dim sql As Stringsql = "INSERT INTO tblConnecting (Date, Member, Name, Company, Phone, Fax, Address, NamesofAttendees, PaymentType, Email) " _ & "Values('" & Today() & "', '" & blnMember & "', '" & Me.txtName.Text & "', '" & Me.txtCompany.Text & "', '" _& Me.txtPhone.Text & "', '" & Me.txtFax.Text &...

Unable to cast object of type 'System.Web.UI.LiteralControl' to type 'System.Web.UI.WebControls.TextBox'.
Hi, any idea why I'm getting the following error?Line 45: protected void CartGrid_RowUpdating(object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e) Line 46: { Line 47: TextBox QuantityTextBox = (TextBox)CartGrid.Rows[e.RowIndex].Cells[2].Controls[0]; Line 48: int Quantity = Convert.ToInt32(QuantityTextBox.Text); Line 49: Are you sure that the control at CartGrid.Rows[e.RowIndex].Cells[2].Controls[0] isn't a LiteralControl?  How are you creating code this in your code?Brent JenkinsASP.NET, C#, Web Developerwww.valewebdesign.co.uk  ...

Unable to cast object of type 'System.Web.UI.LiteralControl' to type 'System.Web.UI.WebControls.TextBox'
Hello, Goal: enter a number in two fields HoursPerUnit and PeoplePerUnit and the value for the third field, TotalHoursPerUnit will populate after the the number in the two fields have been caculated.  Using the code below I receive the error message above.  Please tell me what am I doing wrong? Do I need to cast the text as a literal?  Please help? Thank you in advance, <%@ Page Language="VB" MasterPageFile="Default.master" AutoEventWireup="false" CodeFile="frmHR.aspx.vb" Inherits="frmHR"...

Web resources about - CS0104: 'Image' is an ambiguous reference between 'System.Web.UI.WebControls.Image' and 'System.Drawing.Image' - asp.net.getting-started

Resources last updated: 1/12/2016 5:44:27 PM