Mark Richman provides expert advice, strategy, and software solutions to businesses worldwide. His clients range from the Fortune 500 to small businesses to startups seeking dramatic results. Mark creates and improves business-critical web applications, increasing productivity and maximizing profits.

Visual Studio 2008 Bug Upgrading web site from Visual Studio 2005: compiler error CS1519

I recently upgraded a website to Visual Studio 2008 from Visual Studio 2005 so I could make use of LINQ to SQL. Upon adding my table to a new .dbml file and rebuilding, I was met with this nasty compiler error:

LINQ to SQL compiler error CS1519: Invalid token ‘void’ in class, struct, or interface member declaration

After a few minutes of cursing Microsoft, I figured it out…looks like the compiler version wasn’t updated in the solution
file…the C# 2.0 compiler was still being used and choked on the
partial methods. I went into project properties, downgraded from
framework 3.5 to 2.0, clicked ok, then went back and set it to 3.5 and
clicked ok. After re-adding the reference to System.Data.Linq, the
compile succeeded.

To me, this is a bug in Visual Studio
2008…the scenario where you “upgrade” a Visual Studio 2005 website to
2008 for use with LINQ seems like a common thing, no?

Dave Yancey confirms this behavior for XMLSerializer bugs as well…thanks Dave!

Update (May 23, 2008): I was told the following would also be helpful, though I have not tested it yet:

<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>
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4"
  type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<providerOption name="CompilerVersion" value="v3.5"/>
<providerOption name="OptionInfer" value="true"/>
<providerOption name="WarnAsError" value="false"/>
</compiler>
</compilers>
</system.codedom>

Leave a Reply