Can't set up asp.net mvc 2 RC and spark view engine

断了今生、忘了曾经 提交于 2019-12-24 03:05:41

问题


Does omebody has ideas how to fix "Method not found: 'Void System.Web.Mvc.ViewContext..ctor(System.Web.Mvc.ControllerContext, System.Web.Mvc.IView, System.Web.Mvc.ViewDataDictionary, System.Web.Mvc.TempDataDictionary)'." exception. This solution doesn't work http://dotnetslackers.com/articles/aspnet/installing-the-spark-view-engine-into-asp-net-mvc-2-preview-2.aspx.

Thans for all.


回答1:


I had to download the spark view engine source code (http://sparkviewengine.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=27600). Once I did that I went through each of the projects that had a reference to the 1.0 version of System.Web.Mvc assembly and updated to reference to point to System.Web.Mvc 2.0. From there you can build the solution (in visual studio) and you will find that a whole bunch of tests start to fail. You can attempt to fix them (by adding the additional TextWriter parameter you will find is now needed). You will also see that the SparkView.cs file complains about a missing parameter. In the Render method (line 100 of the source code I downloaded) I had to update the instantiation of the wrappedViewContext to look like this (add writer to the end of the list of parameters):

public void Render(ViewContext viewContext, TextWriter writer)
{
    var wrappedHttpContext = new HttpContextWrapper(viewContext.HttpContext, this);

    var wrappedViewContext = new ViewContext(
        new ControllerContext(wrappedHttpContext, viewContext.RouteData, viewContext.Controller),
        viewContext.View,
        viewContext.ViewData,
        viewContext.TempData,
        writer); //  <-- add the writer to the end of the list of parameters

    ...
}

Once the code is updated you can run the build.cmd script that is in the root of the source you downloaded. The build process will create a zip file in the build/dist folder. Take those new dll's and add them to your website. Things should work once again.




回答2:


At the time of this answer, MVC 2 RC2 bits are available at sparkviewengine.codeplex.com

http://sparkviewengine.codeplex.com/releases/view/41143

It was actually Erik from the post mentioned by R0MANARMY who helped get those bits out there.




回答3:


Looks like you can also download compiled binaries from here. As the post says, it isn't a final (or official) release, but at least it seems like the unit tests pass.



来源:https://stackoverflow.com/questions/2138583/cant-set-up-asp-net-mvc-2-rc-and-spark-view-engine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!