开发者

Automatic Properties not compiling despite adding reference to System.Core.dll

开发者 https://www.devze.com 2022-12-21 03:10 出处:网络
I have a c# v3.5 framework site that I am doing some maintenance on. I wish to use Automatic Properties but whenever I try to add one, the compiler fails [as below]. I have added the System.Core.dll (

I have a c# v3.5 framework site that I am doing some maintenance on. I wish to use Automatic Properties but whenever I try to add one, the compiler fails [as below]. I have added the System.Core.dll (and it is in the web.config ok) but still no joy.

Anyway seen this behavior before and have a resolution?

Thanks,

dan

Error 6 'XXX.Archive开发者_高级运维.TypeOfArchive.get' must declare a body because it is not marked abstract or extern

============


It looks like your application is still being compiled with 2.0 version of the compiler. If it is a web application, you may need to configure the compiler in web.config. See for example this question.

Also, you shouldn't need System.Core.dll to get automatic properties working. Unlike LINQ, automatic properties are purely a feature of the compiler and don't depend on any types from .NET 3.5 libraries.


Do you have the web.config setup to use the 3.5 compiler? It looks like it's still invoking a .0 compiler to build. Example config for C#, place this below </system.web>:

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

Reference config: https://web.archive.org/web/20211020153237/https://www.4guysfromrolla.com/articles/121207-1.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消