C# 2026 - properties all giving me error : does not configure the code serialization for its property content

Christ Kennedy 41 Reputation points
2025-11-30T23:41:29.4933333+00:00

I've started a new project and loaded old .cs files from a previous project.

app won't compile because all my properties are complaining about the same issue

e.g.

      bool bolAllowDecimal = false;
      public bool AllowDecimal
      {
          get { return bolAllowDecimal; }
          set { bolAllowDecimal = value; }
      }


causes error code : Property 'AllowDecimal' does not configure the code serialization for its property content

what is this????!??

Windows development | Windows App SDK
{count} votes

2 answers

Sort by: Most helpful
  1. Christ Kennedy 41 Reputation points
    2025-12-01T00:30:35.5+00:00

    adding

    [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] 
    [DefaultValue(false)]
    

    in front of my properties resolved the issue.

    0 comments No comments

  2. Jay Pham (WICLOUD CORPORATION) 3,060 Reputation points Microsoft External Staff Moderator
    2025-12-01T06:35:40.7066667+00:00

    Hello @Christ Kennedy ,

    Thank you for contact Microsoft Q&A. After review your description, I will clarify why the compilation error occurred and summarize the solution below:

    • Importing old .cs files into a C# 2026 project caused compilation errors for all properties:
    
    Property 'AllowDecimal' does not configure the code serialization for its property content
    
    
    • Example failing code:
    
    bool bolAllowDecimal = false;
    
    public bool AllowDecimal
    
    {
    
        get { return bolAllowDecimal; }
    
        set { bolAllowDecimal = value; }
    
    }
    
    

    This happened because the designer in C# 2026 (Windows App SDK) looks for serialization attributes on the property itself. In the imported code the attributes were applied to the backing field, so the designer ignored them and couldn't configure property serialization which caused the compilation error.

    • In C# 2026 with Windows App SDK, the designer requires explicit serialization attributes on properties, not on backing fields.
    • Initial attempts applied [DesignerSerializationVisibility] and [DefaultValue] to the field instead of the property, so the compiler could not configure serialization.

    As I can see your solution had worked perfectly:

    • Apply attributes directly to the property:
    
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
    
    [DefaultValue(false)]
    
    public bool AllowDecimal
    
    {
    
        get { return bolAllowDecimal; }
    
        set { bolAllowDecimal = value; }
    
    }
    
    
    • After this change, your project compiled successfully.

    You can read more information about property serialization in Windows App SDK here:

    I hope this explanation clarifies the root cause of the compilation errors. If you have any further questions, feel free to ask!


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.