spark view engine Precompilation and extension methods

791 Views Asked by At

In our web project we have added Extension methods in a folder \Code\Extensions\DateTimeExtension.cs containing an extension method called FromUtcToUserTimeZone()

We use the spark view engine in asp.net mvc and want it to work on medium trust there for we need to make a pre compilation of the views.

When the post build event runs I get Error 29 'System.DateTime' does not contain a definition for 'FromUtcToUserTimeZone' c:...\Views\Calendar\Index.spark' I'v added to my view.

Added the webproject it self to the web.config

<spark> 
<compilation debug="false" > 
  <assemblies> 
    <add assembly="System.Web.Mvc" /> 
    <add assembly="....Models" /> 
    <add assembly="...Web" /> 
  </assemblies> 
</compilation> 
<pages automaticEncoding="true"/> 

And its still not working.

1

There are 1 best solutions below

1
On

Did you include namespace containing this method in your view?

<use namespace="YourNamespace"/>

You can place this include in _global.spark or your view. If you place it in _global.spark, you will have access to it in every view.