views:

92

answers:

2

I have a c# v3.5 framework site that I am doing some maintenance on. I wish to use Automatic Properties but whenever I try to add one, the compiler fails [as below]. I have added the System.Core.dll (and it is in the web.config ok) but still no joy.

Anyway seen this behavior before and have a resolution?

Thanks,

dan

Error 6 'XXX.Archive.TypeOfArchive.get' must declare a body because it is not marked abstract or extern

============

+1  A: 

It looks like your application is still being compiled with 2.0 version of the compiler. If it is a web application, you may need to configure the compiler in web.config. See for example this question.

Also, you shouldn't need System.Core.dll to get automatic properties working. Unlike LINQ, automatic properties are purely a feature of the compiler and don't depend on any types from .NET 3.5 libraries.

Tomas Petricek
spot on - thanks
dan m
A: 

Do you have the web.config setup to use the 3.5 compiler? It looks like it's still invoking a .0 compiler to build. Example config for C#, place this below </system.web>:

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

Reference config: http://www.4guysfromrolla.com/articles/121207-1.aspx

Nick Craver
thanks! that did it (marked prev. post as answer but yours was very complete just posted slightly later, much appreciated nick)
dan m