Extension methods not working after upgrading VS 2005 Web Project to VS 2008

by Dominic Zukiewicz 26. August 2009 09:18

A colleague of mine had some problems after recently upgrading an EPiServer site developed in Visual Studio 2005. The site he was developing was brought up to date by using Visual Studio 2008.

After changing the web project build framework to .NET 3.5, the development machine compiled the site no problem. However the problem was that the STAGE Web.config file had not been updated with some extra entries that the upgrade wizard had put in.

The error he was getting was highlighting the “this PageData data”, saying “Type expected”.

public static class EPiServerExtensions
{
    public static bool IsPublished(this PageData data)
    {
        /*........*/
    }
}

Since the stage site had the source code deployed with it, the compiler didn’t know what compiler version to use. In his case it was using .NET 2.0’s compiler instead of .NET 3.5’s compiler.

In order to correct this problem, some web.config settings had to be included in the staging web.config.

<system.codedom>
    <compilers>
        <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4"
                  type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
            <providerOption name="CompilerVersion" value="v3.5"/>
            <providerOption name="WarnAsError" value="false"/>
        </compiler>
    </compilers>
</system.codedom>

After this, it worked perfectly fine!

Tags:

Visual Studio IDE (2005/2008) | EPiServer

Powered by BlogEngine.NET 1.5.0.7
Theme by Interakting

Interakting

A full service digital agency offering online strategy, design and usability, systems integration and online marketing services that deliver real business benefits and ensure your online objectives are met.

Calendar

<<  July 2010  >>
MoTuWeThFrSaSu
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

View posts in large calendar