locked
Auto-Implemented Properties not compiling RRS feed

  • Question

  • Hello,

    I just switched to VS 2008 and noticed the new syntax for properties. Unfortunately, I can't get my project to compile with them. The error messages I'm getting for my properties include the text "must declare a body because it is not marked abstract or extern".

    I've seen some messages about changing the Build->Target Framework from 2.0 to 3.0/3.5, but I already have that set to 3.5

    Anyone know what else I'm missing?

    -cwineman
    Tuesday, January 13, 2009 10:42 PM

Answers

  • The Auto-Implemented Properties functions come with the C#3.0 compiler.

    What is your project type?
    If you create a new console .NET 3.5 application, will the code compile?

    What is your code look like? Please ensure that you use the same as the document states: http://msdn.microsoft.com/en-us/library/bb384054.aspx

    Thanks.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. http://forums.msdn.microsoft.com/en-US/vssetup/thread/60424309-bd78-4ca2-b618-03c4a16123b6
    • Marked as answer by Figo Fei Monday, January 19, 2009 3:18 AM
    Thursday, January 15, 2009 4:41 AM
  • We solved our problem by changing our web.config file to include:

    <providerOption name="CompilerVersion" value="v3.5"/>

    in the "compilers" section.

    -cwineman
    • Marked as answer by Figo Fei Thursday, January 22, 2009 3:24 AM
    Wednesday, January 21, 2009 2:23 PM

All replies

  • The Auto-Implemented Properties functions come with the C#3.0 compiler.

    What is your project type?
    If you create a new console .NET 3.5 application, will the code compile?

    What is your code look like? Please ensure that you use the same as the document states: http://msdn.microsoft.com/en-us/library/bb384054.aspx

    Thanks.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. http://forums.msdn.microsoft.com/en-US/vssetup/thread/60424309-bd78-4ca2-b618-03c4a16123b6
    • Marked as answer by Figo Fei Monday, January 19, 2009 3:18 AM
    Thursday, January 15, 2009 4:41 AM
  • We solved our problem by changing our web.config file to include:

    <providerOption name="CompilerVersion" value="v3.5"/>

    in the "compilers" section.

    -cwineman
    • Marked as answer by Figo Fei Thursday, January 22, 2009 3:24 AM
    Wednesday, January 21, 2009 2:23 PM
  • cwineman said:

    We solved our problem by changing our web.config file to include:

    <providerOption name="CompilerVersion" value="v3.5"/>

    in the "compilers" section.

    -cwineman


    Thank you for coming back with your solution, cwineman.
    It will help others who have the same problem.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. http://forums.msdn.microsoft.com/en-US/vssetup/thread/60424309-bd78-4ca2-b618-03c4a16123b6
    Thursday, January 22, 2009 3:26 AM