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

后端 未结 9 1388
离开以前
离开以前 2021-02-13 20:03

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          


        
相关标签:
9条回答
  • 2021-02-13 20:44

    This also happens on a raw web site project where there was no web.config generated.

    Although the solution file said 3.5, .Net needed the web.config to state it also to recognize. I ran debug allowing it to create a webconfig, and all was working.

    So it is like the answer provided, but just make sure you have one.

    0 讨论(0)
  • 2021-02-13 20:50

    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>
    
    0 讨论(0)
  • 2021-02-13 20:50

    You are correct; that style is allowed.

    I'd look into the standard assemblies referenced. I'm not sure which you'd need to get that to compile, but I figure somewhat you're pointing to the .Net v2.0 version of csc.exe.

    0 讨论(0)
提交回复
热议问题