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

后端 未结 9 1401
离开以前
离开以前 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:32

    This error can also happen if you are using CodeFile="MyControl.ascx.cs" in your MyControl.ascx instead of CodeBehind="MyControl.ascx.cs".

    In case of CodeFile, the 2.0 compiler tries to recompile the page, even if you have a WebProject instead of a WebSite and of course - does fail.

    Changing the attribute name to CodeBehind fixed the problem in my case.

提交回复
热议问题