.NET属性生成和QUOT;必须声明主体,因为它未标记为abstract或EXTERN"编译错误 [英] .NET property generating "must declare a body because it is not marked abstract or extern" compilation error

查看:943
本文介绍了.NET属性生成和QUOT;必须声明主体,因为它未标记为abstract或EXTERN"编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个.NET 3.5(目标框架)的Web应用程序。我有一些代码,看起来像这样:

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."



任何想法?我的理解是,这种风格的财产是作为.NET 3.0中有效。

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

谢谢!


原来,这个问题是在我的.sln文件本身。虽然我改变我的编译选项目标版本,在.sln文件,我发现这一点:

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"

更改,为3.5解决了这个问题。谢谢,伙计们!

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

推荐答案

添加到web.config文件

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>

这篇关于.NET属性生成和QUOT;必须声明主体,因为它未标记为abstract或EXTERN&QUOT;编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆