以下方法或属性之间的调用不明确:

时间:2012-07-17 11:21:20

标签: c# asp.net-mvc

我有2个网站;一个是公共的,另一个是管理员。这些是独立的网站。 theSite.dll用于public,而theSiteCMS用于admin。

下面的代码来自AdminSite,即theSiteCMS。该网站还包含theSite.dll引用,该引用也具有相同的成员函数Html.ActiveLinkImage。

我怀疑我无法隔离这些呼叫;因此错误。 请建议正确的方法。

代码theSiteCMS(管理站点)

<%@ 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 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

2 个答案:

答案 0 :(得分:1)

看起来您有两个不同版本的System.Web.Mvc dll以某种方式引用它并且它不知道要调用哪个。

答案 1 :(得分:1)

我的建议是从'theSiteCMS'删除System.Web.MVC的任何引用(因为'theSite.dll'已经包含它),然后将theSiteDLL添加为项目参考

我认为它们都在同一个解决方案文件中。我希望这会有所帮助。