radimitrov / CSharpShellApp

77 stars 18 forks source link

CS0122 access error on fields in xml #353

Closed Alisis33 closed 5 months ago

Alisis33 commented 6 months ago

Not sure where this error comes from, but the same code works in the old pre Maui version.

Field is x:FieldModifier="public, but no access to the field.

<?xml version="1.0" encoding="UTF-8"?>
<ContentPage 
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"

    xmlns:local="using:TestP"
    x:Class="TestP.FlyoutMenuPage"

    Padding="0,0,0,0"
    BackgroundColor="#000000"
    Title="TestP"
>
<StackLayout BackgroundColor="#000000">

<Label  x:Name="TestL_Label" x:FieldModifier="public" StyleClass="FlyoutTitle" Text="Text"/>

</StackLayout>
</ContentPage>

...

public static FlyoutMenuPage flyoutRoot;

...

TestP.FlyoutMenuPage.flyoutRoot.TestL_Label.Text = "Text";

CS0122 'Der Zugriff auf "FlyoutMenuPage.TestL_Label" ist aufgrund des Schutzgrads nicht möglich.
Alisis33 commented 6 months ago

351 related

devastaza commented 6 months ago

Yep, this bug comes in from new major update for .net. Now we should set xaml objects public if we need it. For some reason before update it didn't work in our Shell.

radimitrov commented 6 months ago

Yes, #351 related and the fix for that should also include x:FieldModifier support. Unless the publicly released app version is before the second commit? Not sure at this point because Google were flowers last week and it took several days of trial and error to make an update change that would have enough sunshine for them.

devastaza commented 6 months ago

Yes, #351 related and the fix for that should also include x:FieldModifier support. Unless the publicly released app version is before the second commit? Not sure at this point because Google were flowers last week and it took several days of trial and error to make an update change that would have enough sunshine for them.

Yep, with update of Shell the problem has been fixed.

Alisis33 commented 6 months ago

Works now in 3.2.34