Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET property generating "must declare a body because it is not marked abstract or extern" compilation error

I have a .NET 3.5 (target framework) web application. I have some code that looks like this:

public string LogPath { get; private set; }
public string ErrorMsg { get; private set; }

It's giving me this compilation error for these lines:

"must declare a body because it is not marked abstract or extern."

Any ideas? My understanding was that this style of property was valid as of .NET 3.0.

Thanks!


The problem turned out to be in my .sln file itself. Although I was changing the target version in my build options, in the .sln file, I found this:

TargetFramework = "3.0"

Changing that to "3.5" solved it. Thanks, guys!

like image 394
Matthew Cole Avatar asked Sep 18 '08 18:09

Matthew Cole


1 Answers

add to web.config

<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>
</system.codedom>
like image 65
R.L. Avatar answered Sep 21 '22 05:09

R.L.