Kendo UI throwing CS1593: Delegate 'System.Act

2019-07-13 12:48发布

问题:

Here is a block of code that was working and now isn't. I am using Kendo UI for MVC. The error is

CS1593: Delegate 'System.Action' does not take 1 arguments.

This was an older site; opening and running shows the working version as VS2010, I did update Kendo and MVC, but not in this project. Any ideas?

@(Html.Kendo().Window()
    .Name("Window")
    .Title("Results")
    .Content(@<text><div class="Result"></div></text>).Draggable()
                                    .Resizable()
                                    .Visible(false)
                                    .Width(450)
                                    .Actions(actions => actions.Minimize().Maximize().Close())
                                    )

回答1:

I found the answer. I had updated from MVC3 to MVC4 This update will break 3 party controls

please read this section of release notes http://www.asp.net/whitepapers/mvc4-release-notes#_Toc303253815

section: Installing ASP.NET MVC 4 breaks ASP.NET MVC 3 RTM applications.

Item 3 in this section was all that wasn't there. Once corrected, everything works fine.



回答2:

In case this is of use to someone else I found that

CS1593: Delegate 'System.Action' does not take 1 arguments.

is potentially a bit of a 'catch all' for errors in the function passed to the Content method.

In my case I was using a Kendo.Mvc.UI.Fluent.SplitterPanBuilder (which has a method signature of public SplitterPaneBuilder Content(Func<object, object> content);) and the error came from where I had changed the namespace of a class used and not updated it.

To better illustrate this here is some (pseudo-ish) code which caused the error

verticalPanes.Add()
  .Content
  (
        @<div class="pane-content" id=@panelName>
          @(Html.Kendo().Grid<OldInvalidNameSpace.Person>().Name(reportGridName))
        </div>
  )

and changing to this:

verticalPanes.Add()
  .Content
  (
        @<div class="pane-content" id=@panelName>
          @(Html.Kendo().Grid<NewValidNameSpace.Person>().Name(reportGridName))
        </div>
  )

resolved it.

In my mind the error does really help pinpoint the cause, but maybe knowing this will help someone else!