user1511069
user1511069

Reputation: 339

The call is ambiguous between the following methods or properties:

I have 2 websites; One is for Public and other for admin.These boith are seperate websites. theSite.dll is for public and theSiteCMS for admin.

The code below is from AdminSite i.e theSiteCMS.This site also contains theSite.dll reference which also has same member functions Html.ActiveLinkImage.

I doubt that I am not able to isolate these call ;hence the error. Kindly suggest the right way.

Code theSiteCMS(admin site)

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<theSiteCMS.Helpers.Pagination<theSiteCMS.Models.Article>>"%>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Articles Management
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <script type="text/javascript" language="javascript">
        function goToPage(pageIndex) {
            $("#page").val(pageIndex);
            $('#SearchForm').submit();
        }

        function sortField(fld, sortDirection) {
            $("#sort_field").val(fld);
            $("#sort_dir").val(sortDirection);
            $('#SearchForm').submit();
            return false;
        }     
    </script>
    <h2>Articles Management</h2>
    <% string[] articles_status = { "Draft", "Submitted", "Published", "Archived", "Deleted" }; %>
    <% var _gridState = (theSiteCMS.Controllers.ArticlesController.GridState)ViewData["GridState"];
       var queryCollection = new { 
                    sort_field= _gridState.sort.field
                    ,sort_dir = (_gridState.sort.direction == theSiteCMS.Controllers.AppController.SortDirection.Descending) ? "desc" : "asc"
                    ,status = _gridState.status
                    ,keyword = _gridState.keyword
                    ,username = _gridState.username
                    ,section_id = _gridState.section_id
                    ,category_id = _gridState.category_id
                    ,page = _gridState.page
       };
    %>
    <%Html.BeginForm("index", "Articles", FormMethod.Post, new { id="SearchForm"}); %>   
    <table width="100%">
        <tr>
            <td width="16%">Status</td>
            <td width="16%">Section</td>
            <td width="16%">Category</td>
            <!--td width="16%">Published</td-->
            <td width="16%">User</td>
            <td width="16%">Keyword</td>
            <td width="4%">&nbsp;</td>
        </tr>
        <tr>
        <td><%= Html.DropDownList("status", theSiteCMS.Controllers.ArticlesController.ArticleStatusList(_gridState.status), "ALL", new { onchange = "this.form.submit();" })%></td>
        <td><%= Html.DropDownList("section_id", theSiteCMS.Controllers.SectionsController.SectionsList(_gridState.section_id), "--select all--", new { onchange = "this.form.submit();" })%></td>
        <td><%= Html.DropDownList("category_id", theSiteCMS.Controllers.SectionsController.CategoriesList(_gridState.section_id, _gridState.category_id), "--select all--", new { onchange = "this.form.submit();" })%></td>
        <!--td><%/* Html.jQuery().DatePicker()
                    .Name("publish_at")
                    .DateFormat("mm-dd-yy")
                    .NavigationAsDateFormat(true)
                    .HtmlAttributes(new { style="width:100px"})
                    .Render();*/ %></td-->
        <td><%= Html.TextBox("username", _gridState.username, new { style = "width:100px" })%></td>
        <td><%= Html.TextBox("keyword", _gridState.keyword, new { style="width:100px"})%></td>
        <td width="15%"><input type="submit" value="find" /></td>
        </tr>
    </table>
    <%=Html.Hidden("sort_dir", _gridState.sort.direction == theSiteCMS.Controllers.AppController.SortDirection.Descending?"desc":"asc") %>
    <%=Html.Hidden("sort_field", _gridState.sort.field) %>

    <%=Html.Hidden("page", _gridState.page) %>
   <%Html.EndForm(); %>


   <hr />

    <table width ="100%">
    <caption><%= ViewData["Message"] %></caption>
        <tr>
            <th>Action</th>
           <th><%= Html.ActionLink("Title", "Index", new { action="Index"}, new { @class = Html.GetSortCssClass(_gridState.sort, "title"), onclick = "return sortField('title','asc');" })%></th>
            <th><%= Html.ActionLink("Author", "Index", new { action="Index"}, new { @class = Html.GetSortCssClass(_gridState.sort, "user_id"), onclick = "sortField('user_id','asc');return false;" })%></th>
            <th><%= Html.ActionLink("Date", "Index", new { action="Index"}, new { @class = Html.GetSortCssClass(_gridState.sort, "publish_at"), onclick = "sortField('publish_at','asc');return false;" })%></th> 
            <th><%= Html.ActionLink("Status", "Index", new { action="Index"}, new { @class = Html.GetSortCssClass(_gridState.sort, "status"), onclick = "sortField('status','asc');return false;" })%></th>           
            <th>
                Comments
            </th>
            <th>
                View count
            </th>
        </tr>

    <% foreach (var item in Model)
       { %>

        <tr>
            <td width="100">
                <%=Html.ActionLinkImage("Edit", Url.Content("~/images/icons/pencil.png"), "Edit", new { action = "Edit", id = item.id }, new { title = "Edit" })%>
                <%=Html.ActionLinkImage("View", Url.Content("~/images/icons/eye.png"), "Details", new { action = "Details", id = item.id }, new { title = "View" })%><br />
                <% if (item.status ==0){ //draft%>
                    <%=Html.Image("~/images/icons/application_edit.png", new {@class="disabled"}) %>
                <%} else {%>
                    <%=Html.ActionLinkImage("Draft", Url.Content("~/images/icons/application_edit.png"), "changeStatus", new { action = "changeStatus", id = item.id, s = 0 }, new { title="Draft"})%>
                <%} %> 

                <% if (item.status ==1){ //submit%>
                    <%=Html.Image("~/images/icons/application_go.png", new {@class="disabled"}) %>
                <%} else {%>
                    <%=Html.ActionLinkImage("Draft", Url.Content("~/images/icons/application_go.png"), "changeStatus", new { action = "changeStatus", id = item.id, s = 1 }, new { title = "Submit" })%>
                <%} %> 
                <% if (item.status ==2){ //publish %>
                    <%=Html.Image("~/images/icons/accept.png", new {@class="disabled"}) %>
                <%} else {%>
                    <%=Html.ActionLinkImage("Publish", Url.Content("~/images/icons/accept.png"), "changeStatus", new { action = "changeStatus", id = item.id, s = 2 }, new { title = "Publish" })%>
                <%} %>                                  
                <% if (item.status ==3){ //archive %>
                    <%=Html.Image("~/images/icons/compress.png", new {@class="disabled"}) %>
                <%} else {%>
                    <%=Html.ActionLinkImage("Archive", Url.Content("~/images/icons/compress.png"), "changeStatus", new { action = "changeStatus", id = item.id, s = 3 }, new { title = "Archive" })%>
                <%} %>
                <% if (item.status ==4){ //deleted %>
                    <%=Html.Image("~/images/icons/application_delete.png", new {@class="disabled"}) %>
                <%} else {%>
                    <%=Html.ActionLinkImage("Archive", Url.Content("~/images/icons/application_delete.png"), "changeStatus", new { action = "changeStatus", id = item.id, s = 4 }, new { title = "Delete" })%>
                <%} %>                     
            </td>
            <td>
                <%= Html.Encode(item.title)%><br/>
                <%= Html.Encode(item.Category.Section.title)%> , <%= Html.Encode(item.Category.title)%>
            </td>
            <td>
                <%= Html.Encode(item.User.username)%>
            </td>

            <td>
                <%= Html.Encode(String.Format("{0:g}", item.publish_at))%>
            </td>

            <td>
                <%= Html.Encode(articles_status[item.status])%>
            </td>
            <td>                
                <%= Html.Encode(item.Comments.Count())%>
            </td>
            <td>
                <%= Html.Encode(item.viewcount)%>
            </td>

        </tr>

    <% } %>

    </table>

    <div class="pagination">
        <% if (Model.HasPreviousPage)
           { %>
            <%= Html.RouteLink("previous",
                               "Default",
                               new { page = (Model.PageIndex - 1) })%>

        <% }
           else
           { %>
           previous
        <%} %>
         | 
        <% if (Model.HasNextPage)
           { %>

            <%= Html.RouteLink("next",
                               "Default",
                               new { page = (Model.PageIndex + 1) })%>

        <% }
           else
           { %>    
           next
        <%} %>
    </div>
</asp:Content>

The Error I get:

The call is ambiguous between the following methods or properties:
'System.Web.Mvc.Html.HtmlExtensions.ActionLinkImage(System.Web.Mvc.HtmlHelper, string, string, string, object, object)'
 and
'System.Web.Mvc.Html.HtmlExtensions.ActionLinkImage(System.Web.Mvc.HtmlHelper, string, string, string, object, object)'
\My Documents\Visual Studio 2008\Projects\3ICMS\Views\Articles\Index.aspx   111 
------
The call is ambiguous between the following methods or properties:
'System.Web.Mvc.Html.HtmlExtensions.ActionLinkImage(System.Web.Mvc.HtmlHelper, string, string, string, object, object)'
'System.Web.Mvc.Html.HtmlExtensions.ActionLinkImage(System.Web.Mvc.HtmlHelper, string, string, string, object, object)'
\My Documents\Visual Studio 2008\Projects\3ICMS\Views\Articles\Index.aspx   116 
------
The call is ambiguous between the following methods or properties:
'System.Web.Mvc.Html.HtmlExtensions.ActionLinkImage(System.Web.Mvc.HtmlHelper, string, string, string, object, object)' 
and
'System.Web.Mvc.Html.HtmlExtensions.ActionLinkImage(System.Web.Mvc.HtmlHelper, string, string, string, object, object)' 
\My Documents\Visual Studio 2008\Projects\3ICMS\Views\Articles\Index.aspx   106 
------
The call is ambiguous between the following methods or properties:
'System.Web.Mvc.Html.HtmlExtensions.ActionLinkImage(System.Web.Mvc.HtmlHelper, string, string, string, object, object)' and
'System.Web.Mvc.Html.HtmlExtensions.ActionLinkImage(System.Web.Mvc.HtmlHelper, string, string, string, object, object)' 
\My Documents\Visual Studio 2008\Projects\3ICMS\Views\Articles\Index.aspx   101

Upvotes: 1

Views: 4873

Answers (2)

Som Poddar
Som Poddar

Reputation: 1451

My suggestion will be to remove any reference of System.Web.MVC from 'theSiteCMS' (since 'theSite.dll' already contains it) and then add theSiteDLL as project referece.

I am assumming both of them are inside the same solution file. I hope this helps.

Upvotes: 1

Trevor Pilley
Trevor Pilley

Reputation: 16393

It looks like you have 2 different versions of the System.Web.Mvc dll referenced somehow and it doesn't know which to call.

Upvotes: 1

Related Questions