我有一个.NET 3.5(目标框架)Web应用程序。
public string LogPath { get; private set; }
public string ErrorMsg { get; private set; }
它给了我这些行的编译错误:
"must declare a body because it is not marked abstract or extern."
有什么想法吗?我的理解是,这种类型的属性在.NET 3.0中是有效的。
问题发生在我的.sln文件本身中。尽管我在构建选项中更改了目标版本,但在.sln文件中,我发现了以下内容:
TargetFramework = "3.0"
把它改成3.5解决了。
发布于 2018-05-31 08:52:18
添加到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>
发布于 2018-05-31 10:04:37
你的代码是有效的-它应该工作良好。进入项目的属性页,确保“目标框架”是.NET 3.0或3.5。
https://stackoverflow.com/questions/-100000169
复制相似问题