Reputation: 203
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"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Prepify.App.Pages.MainMenu"
xmlns:controls="clr-namespace:ImageCircle.Forms.Plugin.Abstractions;assembly=ImageCircle.Forms.Plugin.Abstractions"
BackgroundColor="White"
Title="Menu">
<StackLayout VerticalOptions="FillAndExpand">
<ListView
Header="{Binding .}"
SeparatorColor="{StaticResource dividerColor}"
HasUnevenRows="True"
ItemSelected="AppMenu_OnItemSelected"
ItemTapped="AppMenu_OnItemTapped"
ItemsSource="{Binding Items}"
x:Name="appMenu">
<ListView.HeaderTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="30"/>
<ColumnDefinition Width="10"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="80"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="5"/>
</Grid.RowDefinitions>
<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" />
</Grid>
</DataTemplate>
</ListView.HeaderTemplate>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Orientation="Horizontal" >
<StackLayout.Padding>
<OnPlatform x:TypeArguments="Thickness" Android="15,15,15,15" iOS="25,12,15,12" />
</StackLayout.Padding>
<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}"/>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ContentPage>
Markup of only page that does work (note, no bindings anywhere):
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Prepify.App.Pages.Root"
xmlns:pages="clr-namespace:Prepify.App.Pages;assembly=Prepify.App"
MasterBehavior="Popover"
Title="Make Preparedness Easy">
<MasterDetailPage.Master>
<pages:MainMenu/>
</MasterDetailPage.Master>
</MasterDetailPage>
I'm using all the latest as of posting this question. Visual Studio 2015 Xamarin.Forms 2.3.3.193 Xamarin.VS 4.3.0.784
Upvotes: 3
Views: 3629
Reputation: 3209
I solve it by removing all this lines from the PCL project, not sure what is the impact though.
[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
Upvotes: 0
Reputation: 203
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.
Upvotes: 2
Reputation: 41
I had the exact same issue for a project that contains exactly ONE Page (xaml + cs) and ONE ViewModel. I changed one line, saved the chance and it didn't build anymore, also with this error:
Value cannot be null.
Parameter name: method
In my case changing the package version fixed it. Just right click on your project > open the Properties > open Package Tab on the left > and increase the Package version number. And of course, I did many many Clean and Rebuilds on my Solution.
This is what worked for me, but I have to confess that I just got started with Xamarin, so I dont really know what Im doing :D Maybe this is helpful to anyone.
Oh and maybe important to say: Im working with Xamarin 3.2.0.839982 in Visual Studio 2017
Upvotes: 4
Reputation: 16232
WARNING: this isn't a proper answer, but that's too long for a comment. Answer it is then.
I took the XAML you pasted and used it in a new and fresh Xamarin.Forms project (referencing XF 2.3.3.180 (tried with .193 as well) and ImageCircle 1.8.1) stubbed the 2 event handlers, added the [XamlCompilation]
attribute and it compiles just fine.
If you can't narrow down your issue and still think it's an issue in Xamarin.Forms, you should open a bug report with a reproduction case at https://bugzilla.xamarin.com/enter_bug.cgi?product=Forms. You can even ping me when it's done so I'll look at it.
Upvotes: 0