[FIXED] Regressed Issue: XamlCompilation error Value cannot be null, Parameter name: method


I searched SO to find this issue, but the answer didn’t work for me so the issue still exists.

Personally, I believe the issue is probably related to some configuration “thing”, but I would have no idea where to start looking to resolve it. To my knowledge, I have not altered any config settings out of norm (just used standard new project approach). Here is some detail on my issue:

Just so happens that today is first time trying out the XamlC feature. At first I tried the assembly level attribute in my App.cs file:

[assembly: XamlCompilation(XamlCompilationOptions.Compile)]

After compiling, I was getting a bunch of errors that were all identical. I also got a a different error on any page using a TemplateControl. So I pulled it off the assembly level and put a single class-level attribute on one page, and it still failed with the same error:

Value cannot be null.
Parameter name: method

I poked around on Stackoverflow and found that about a year ago someone had the same issue (here), but they said they resolved it by upgrading Xam Forms to latest version. Since I’m on the latest stable versions, I have no where to go there.

I tried this class-level attribute on several pages in my app and only found it to work on a single page in my entire app… just so happens this page has zero bindings in the XAML markup. I’m wondering if a bug was introduced that causes it to blow up.

Markup of page that doesn’t work:

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
    <StackLayout VerticalOptions="FillAndExpand">
            Header="{Binding .}"
            SeparatorColor="{StaticResource dividerColor}"
            ItemsSource="{Binding Items}"

                            <ColumnDefinition Width="10"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="30"/>
                            <ColumnDefinition Width="10"/>
                            <RowDefinition Height="30"/>
                            <RowDefinition Height="80"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="5"/>

                        <BoxView Grid.ColumnSpan="4" Grid.RowSpan="4" BackgroundColor="{StaticResource grayDark}"/>
                        <controls:CircleImage Grid.Column="1" Grid.Row="1" HorizontalOptions="Start" VerticalOptions="End" Source="{Binding ProfileImageUrl}" WidthRequest="75" HeightRequest="75"/>
                        <Label Grid.Column="1" Grid.Row="2" Text="{Binding FullName}"/>
                        <ActivityIndicator Grid.Column="2" Grid.Row="2" IsVisible="{Binding IsBusy}" IsRunning="{Binding IsBusy}" Color="White" WidthRequest="20" HeightRequest="20" VerticalOptions="Center" />

                        <StackLayout Orientation="Horizontal" >
                                <OnPlatform x:TypeArguments="Thickness" Android="15,15,15,15" iOS="25,12,15,12" />
                            <Image Source="{Binding Icon}" VerticalOptions="Center" WidthRequest="20" HeightRequest="20"/>
                            <Image WidthRequest="20"/>
                            <Label Text="{Binding Label}" VerticalOptions="Center" TextColor="{Binding LabelColor}" Style="{DynamicResource ListItemTextStyle}"/>

Markup of only page that does work (note, no bindings anywhere):

<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
    Title="Make Preparedness Easy">



I’m using all the latest as of posting this question.
Visual Studio 2015


So… after getting your feedback and some from here, I just decided to try and rebuild my PCL from scratch. After hours of painstakingly migrating files over one at a time and ensuring the XamlCompilation worked at every step along the way, I got it to work build with no errors. Then I just copied the new projects I had made (2 PCLs) right over top the old ones and the solution compiled perfectly.

Answer: ??? There is none. This was a total fluke. There is nothing I learned along the way that could pinpoint the cause of the issue. If you get this issue, try rebuilding your PCL from scratch using the standard project template.

Answered By – Britton

Answer Checked By – Willingham (Easybugfix Volunteer)

Leave a Reply

(*) Required, Your email will not be published