2017-03-02 77 views
1

我搜索了SO找到this問題,但答案沒有爲我工作,所以問題依然存在。迴歸問題:XamlCompilation錯誤值不能爲空,參數名稱:方​​法

就我個人而言,我認爲這個問題可能與某些配置「東西」有關,但我不知道從哪裏開始尋找解決方法。據我所知,我沒有改變任何配置設置超出標準(只是使用標準的新項目方法)。這裏是我的問題上的一些細節:

就這樣發生,今天是第一次嘗試XamlC功能。起初,我試着在我App.cs文件彙編級屬性:

[assembly: XamlCompilation(XamlCompilationOptions.Compile)] 

編譯後,我得到一大堆的都是相同的錯誤。我在使用TemplateControl的任何頁面上也遇到了不同的錯誤。所以我把它關閉的裝配水平,把一個單一的類級屬性在一個頁面上,它仍然失敗,相同的錯誤:

Value cannot be null. 
Parameter name: method 

我捅圍繞#2,發現大約一年前有人有同樣的問題(這裏),但他們表示他們通過將Xam Forms升級到最新版本來解決這個問題。由於我在最新的穩定版本,我沒有去那裏。

我在我的應用程序的幾個頁面上試過這個類級屬性,只發現它在我的整個應用程序的單個頁面上工作......只是發生這個頁面在XAML標記中有零綁定。我想知道是否引入了一個導致它炸燬的bug。

標記網頁的不工作:

<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> 

標記單頁面,做工作(注意,沒有任何地方綁定):

<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> 

我使用所有的最新作張貼這個問題。 的Visual Studio 2015年 Xamarin.Forms 2.3.3.193 Xamarin.VS 4.3.0.784

回答

0

所以......在得到您的反饋意見後,我從here獲得了一些反饋意見,然後我決定嘗試重新構建我的PCL。經過幾個小時艱苦的文件遷移工作,並確保XamlCompilation在每一步都能夠正常工作,我就可以毫無問題地完成工作。然後,我剛剛將所做的新項目(2個PCL)複製到所告知的項目上,並且解決方案完美編譯。

回答:???空無一人。這完全是一種僥倖,我一路上都沒有學到什麼能夠明確問題的原因。如果遇到此問題,請嘗試使用標準項目模板從頭開始重新構建PCL。

0

WARNING: this isn't a proper answer, but that's too long for a comment. Answer it is then.

我把你的XAML和粘貼在一個新的和新鮮的Xamarin.Forms項目中使用它(引用XF 2.3.3.180(也試過.193)以及ImageCircle 1.8.1)對2個事件處理程序進行了修剪,添加了[XamlCompilation]屬性,它編譯得很好。

如果您無法縮小問題範圍,但仍然認爲這是Xamarin.Forms中的問題,您應該打開一個帶有複製案例的錯誤報告https://bugzilla.xamarin.com/enter_bug.cgi?product=Forms。你甚至可以在完成之後ping我,這樣我就可以看到它。

相關問題