Click here to monitor SSC

Andrew Siemer

Getting Spark View Engine to work with ASP.NET MVC

Published Sunday, January 31, 2010 8:41 PM

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)'

I am finding that there are several complaints about getting Spark View Engine to work with ASP.NET MVC.  I had to tweak the Spark View Engine code base to get things running again.

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.

by asiemer

Comments

 

tylerl said:

Don't go replacing ALL the System.Web.Mvc references to version 2; that's not necessary. The only project where you need to make this switch is Spark.Web.Mvc2. After doing so, make the appropriate change in SparkView.cs (just file in that one project, not ALL the SparkView.cs files), and build.

You should get no errors or test failures.  Use the ..Mvc2 assembly in your project.

There's a funny little idiosyncrasy in the Mvc2 .csproj file such that it references the version 1 MVC DLL, built the hint path points to a version 2 DLL. Apparently the compiler notices the version, ignores the hint, and picks up the ver 1 DLL from elsewhere. Presumably the file that was originally referenced was a version 1 DLL, which got replaced by a version 2 file, though the csproj file was never updated.
February 6, 2010 3:08 AM
You need to sign in to comment on this blog
<January 2010>
SuMoTuWeThFrSa
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456
How to Kill a Company in One Step or Save it in Three
 The majority of companies that suffer a major data loss subsequently go out of business. Wesley David... Read more...

Migrating from OCS 2007 R2 to Lync: Part 4
 Having migrated the rest of our users and legacy resources across and started getting ready to... Read more...

Automated Script-generation with Powershell and SMO
 In the first of a series of articles on automating the process of building, modifying and copying SQL... Read more...

Seth Godin: Big in the IT Business
 Seth Godin has transformed our understanding of marketing in IT. He invented the concept of 'permission... Read more...

Using SQL Test Database Unit Testing with TeamCity Continuous Integration
 With database applications, the process of test and integration can be frustratingly slow because so... Read more...