简体   繁体   中英

Xamarin Resource.Designer.cs generating const instead of static

I have on .NET 6 project using xamarin.android where the resource designer file generated with an error CS0131: The left-hand side of an assignment must be a variable, property or indexer :

public static void UpdateIdValues()
{
    global::MyGame.Resource.Color.alignment_marker_color = global::MyGame.Resource.Color.alignment_marker_color;
    global::MyGame.Resource.Color.white_transparent = global::MyGame.Resource.Color.white_transparent;
    global::MyGame.Resource.Dimension.alignment_marker_height = global::MyGame.Resource.Dimension.alignment_marker_height;
    // ...
}

with values generated like so:


public partial class Color
{
            
    // aapt resource value: 0x7F010000
    public const int alignment_marker_color = 2130771968;

    // aapt resource value: 0x7F010001
    public const int white_transparent = 2130771969;
    // ...

}

Is it an issue with the xamarin dependency? If so, is it something i can solve through nuget? do.net workload?

I had this issue myself, and after much trial and error, I found that the issue was caused by me having two assemblies, both containing Resources which had the same "Default Namespace" in their project properties.

After changing the namespace in one of them, deleting the bin and obj folders, running a Clean (overkill) I was able to successfully rebuild the project without error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM