Bug 27968 - Resource dictionary throws an Exception when inheriting from a subclass of ContentPage
Summary: Resource dictionary throws an Exception when inheriting from a subclass of Co...
Status: VERIFIED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.4.0
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Stephane Delcroix
URL:
Depends on:
Blocks:
 
Reported: 2015-03-12 12:13 UTC by John Miller [MSFT]
Modified: 2015-09-25 07:20 UTC (History)
7 users (show)

Tags: ac all xaml resources
Is this bug a regression?: ---
Last known good build:


Attachments
Sample Project (4.63 MB, application/zip)
2015-03-13 08:31 UTC, Parmendra Kumar
Details
Resource Dictionary Bug Sample (11.03 KB, application/octet-stream)
2015-03-16 12:52 UTC, Andrew
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
VERIFIED FIXED

Description John Miller [MSFT] 2015-03-12 12:13:42 UTC
**Overview:**

   Resources for a Page fail when that Page is a custom subclass of ContentPage. 

**Steps to Reproduce:**

   This fails:
<ContentPage.Resources>
        <ResourceDictionary>
         .....
</ContentPage.Resources>

**Actual Results:**

   An exception is thrown

**Expected Results:**

   No exception

**Additional Information:**

   The workaround is to do this:

<common:BasePage.Resources>
        <ResourceDictionary>
          ....
</common:BasePage.Resources>

where "common" is the namespace that the BasePage exists in.
Comment 1 Parmendra Kumar 2015-03-13 08:31:07 UTC
Created attachment 10320 [details]
Sample Project
Comment 2 Parmendra Kumar 2015-03-13 08:31:37 UTC
I have checked this issue and unable to reproduce it. Could you please check the attached sample and screencast and Let me know if I have missed anything. 

Screencast: http://www.screencast.com/t/horYAXWcq

Application Output: https://gist.github.com/Parmendrak/08e15b24eaa619052b30
BuildOutput: https://gist.github.com/Parmendrak/58e1897a8a349b8b2468

Environment info:

=== Xamarin Studio ===

Version 5.8 (build 443)
Installation UUID: 1a096c6f-0678-402e-89b2-a2c10f7e80e4
Runtime:
	Mono 3.12.1 ((detached/b7764aa)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312010000

=== Apple Developer Tools ===

Xcode 6.2 (6776)
Build 6C131e

=== Xamarin.iOS ===

Version: 8.8.0.2 (Business Edition)
Hash: ccfcd59
Branch: 
Build date: 2015-03-10 02:20:32-0400

=== Xamarin.Android ===

Version: 4.20.0.37 (Business Edition)
Android SDK: /Users/360_macmini/Desktop/android-sdk-macosx
	Supported Android versions:
		2.1    (API level 7)
		2.2    (API level 8)
		2.3    (API level 10)
		3.1    (API level 12)
		4.0    (API level 14)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Xamarin.Mac ===

Version: 1.10.0.21 (Business Edition)

=== Build Information ===

Release ID: 508000443
Git revision: 73883239470cbe8e261c94d95f7c3d0452fd393b
Build date: 2015-03-10 07:22:51-04
Xamarin addins: a2ff7b617f09d9c45d8bbf3d010b5db0d7d36100

=== Operating System ===

Mac OS X 10.9.4
Darwin ShrutiMac.local 13.3.0 Darwin Kernel Version 13.3.0
    Tue Jun  3 21:27:35 PDT 2014
    root:xnu-2422.110.17~1/RELEASE_X86_64 x86_64
Comment 3 Andrew 2015-03-13 09:12:25 UTC
My page looks like this when I use a custom base class:

<common:BasePage
	xmlns="http://xamarin.com/schemas/2014/forms" 
	xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
	x:Class="Mobile.Forms.Release.Pages.AdvocacyPage"
	xmlns:common="clr-namespace:PSEA.Mobile.Pages.Controls;assembly=PSEA.Mobile.Pages" 
    xmlns:ctrl="clr-namespace:PSEA.Mobile.Data.Controls;assembly=PSEA.Mobile.Data" 
    xmlns:data="clr-namespace:PSEA.Mobile.Pages.ViewModel;assembly=PSEA.Mobile.Pages" 
    xmlns:local="clr-namespace:PSEA.Mobile.Pages.Constants;assembly=PSEA.Mobile.Pages" 
    xmlns:cell="clr-namespace:PSEA.Mobile.Data.Controls.Cells;assembly=PSEA.Mobile.Data" 
    xmlns:myb="clr-namespace:Mobile.Forms.Release.Behaviors;assembly=Mobile.Forms.Release" 
    xmlns:val="clr-namespace:PSEA.Mobile.Data.Validators;assembly=PSEA.Mobile.Data" 
    xmlns:g="clr-namespace:PSEA.Mobile.Data.Converters;assembly=PSEA.Mobile.Data" 
    xmlns:cvt="clr-namespace:PSEA.Mobile.Data.Converters;assembly=PSEA.Mobile.Data" 
	x:Name="AdvocacyPage"
	Title="Advocacy">
    <common:BasePage.Resources>
        <ResourceDictionary>
          <DataTemplate x:Key="AndroidItemTemplate">          	
            <cell:MyViewCell>
                  <ViewCell.View>
                      <StackLayout
                        HorizontalOptions="FillAndExpand"
                          VerticalOptions="FillAndExpand"
                          Padding="0, 5, 0, 5">
                      <Grid
                          HorizontalOptions="FillAndExpand"
                          VerticalOptions="FillAndExpand"
                          Padding="0, 10">
                          <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                         <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="40" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Image Source="{Binding ImageName, Converter={StaticResource imgConverter}}" 
                            Grid.Column="0" Grid.Row="0" HeightRequest="36" Grid.RowSpan="2" WidthRequest="36"
                            HorizontalOptions="Center" VerticalOptions="Start"></Image>                        
                        <StackLayout
                            HorizontalOptions="FillAndExpand"
                            VerticalOptions="FillAndExpand"
                            Orientation="Horizontal"
                            Grid.Column="1" Grid.Row="0">
                             <Label Text="{Binding Title}" HorizontalOptions="FillAndExpand"
                                VerticalOptions="FillAndExpand"
                                FontAttributes="Bold"
                                TextColor="{g:GlobalResource HeadingFontColor}"
                                FontSize="{g:GlobalResource HeadingFontSize}"
                                FontFamily="{g:GlobalResource HeadingFontName}">
                             </Label>
                        </StackLayout>
                        <StackLayout
                            HorizontalOptions="FillAndExpand"
                            VerticalOptions="FillAndExpand"
                            Orientation="Horizontal"
                            	Grid.Column="1" Grid.Row="1">
                            	 <Label Text="{Binding Teaser}" 
                                  HorizontalOptions="FillAndExpand"
                                 	VerticalOptions="FillAndExpand"
                                  FontSize="{g:GlobalResource DetailFontSize}" 
                                  FontFamily="{g:GlobalResource DetailFontName}">
                              </Label>
                        </StackLayout>
                      </Grid>
                      </StackLayout>
                  </ViewCell.View>
              </cell:MyViewCell>
          </DataTemplate>
          <DataTemplate x:Key="iOSItemTemplate">
            <cell:MyViewCell RenderID="AdvocacyCell" ShowDisclousure="false" ShowSeparator="false" RenderSize="false">
 					<StackLayout
                        HorizontalOptions="FillAndExpand"
                          VerticalOptions="FillAndExpand"
                            Padding = "0, 5, 10, 5">
                      <Grid
                          HorizontalOptions="FillAndExpand"
                          VerticalOptions="FillAndExpand"
                          RowSpacing="0"
                          Padding="0, 10">
                          <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                         <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="40" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Image Source="{Binding ImageName, Converter={StaticResource imgConverter}}" 
                            Grid.Column="0" Grid.Row="0" HeightRequest="36" Grid.RowSpan="2" WidthRequest="36"
                            HorizontalOptions="Center" VerticalOptions="Start"></Image>                        

                         <Label Text="{Binding Title}" HorizontalOptions="FillAndExpand"
                             VerticalOptions="FillAndExpand" Grid.Column="1" Grid.Row="0"
                             TextColor="{g:GlobalResource HeadingFontColor}" 
                             FontAttributes="Bold" 
                             FontSize="{g:GlobalResource HeadingFontSize}"
                             FontFamily="{g:GlobalResource HeadingFontName}">
                         </Label>
                         <Label Text="{Binding Teaser}" HorizontalOptions="FillAndExpand"
                             VerticalOptions="FillAndExpand" 
                             FontSize="{g:GlobalResource DetailFontSize}" 
                             FontFamily="{g:GlobalResource DetailFontName}" Grid.Column="1" Grid.Row="1">
                          </Label>
                      </Grid>
                      </StackLayout>
              </cell:MyViewCell>
          </DataTemplate>
          <ctrl:PlatformDataTemplateSelector x:Key="TableTemplateSelector" 
          		IOS="{StaticResource iOSItemTemplate}" 
          		Android="{StaticResource AndroidItemTemplate}"/>
        </ResourceDictionary>
      </common:BasePage.Resources>
  <ContentPage.Content>
	<StackLayout
		HorizontalOptions="FillAndExpand"
		VerticalOptions="FillAndExpand"
		Padding="0,0">
   <Grid
       BackgroundColor="Transparent"
       RowSpacing="0"
        VerticalOptions="FillAndExpand">
        <Grid.RowDefinitions>
              <RowDefinition Height="Auto"></RowDefinition>
          <RowDefinition Height="*"></RowDefinition>
          <RowDefinition Height="Auto"></RowDefinition>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="*"></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <StackLayout  Grid.Column="0" Grid.Row="0" 
            VerticalOptions="StartAndExpand"
            HorizontalOptions="FillAndExpand">
             <StackLayout
                VerticalOptions="StartAndExpand"
                HorizontalOptions="StartAndExpand"
                Padding="10, 10, 5, 0">
                <Label Text="{Binding WelcomeMessage}"
                    FontAttributes="Bold" FontSize="18" VerticalOptions="Center" YAlign="Center" />        
            </StackLayout>
            <ctrl:MySeparator Thickness="1" Color="Black" StrokeType="Solid" />
        </StackLayout>
        <ctrl:MyPlatformListView Grid.Column="0" Grid.Row="1" 
            HasUnevenRows="true"
            IsGroupingEnabled="false"
            VerticalOptions="FillAndExpand"
            ItemsSource="{Binding News, Mode=TwoWay}"
            Props="RenderID,AdvocacyCell,ShowDisclousure,false,ShowSeparator,false,RenderSize,false" 
            TemplateSelector="{StaticResource TableTemplateSelector}">
		    <ListView.Behaviors>
		     	<myb:ItemSelectedBehavior 
		     		StaySelected="false" 
		     		CommandName="ItemTapped" 
		     		CommandParameter="SelectedItem" 
		     		CommandNameContext="{x:Reference AdvocacyPage}"></myb:ItemSelectedBehavior>
		     </ListView.Behaviors>	
           </ctrl:MyPlatformListView>
     <StackLayout Grid.Column="0" Grid.Row="2" 
        HorizontalOptions="FillAndExpand"
        VerticalOptions="FillAndExpand"
        Padding="0,10,0,10"
        BackgroundColor="{g:GlobalResource PSEAColor}">
          <StackLayout
              HorizontalOptions="Center"
              VerticalOptions="Center"
              Orientation="Horizontal">   
                  <Image Source="{cvt:ImageResource facebook.png}" BackgroundColor="Transparent" HeightRequest="40" WidthRequest="40">
                  <Image.GestureRecognizers>
                  	<TapGestureRecognizer Command="{Binding ButtonTappedCommand}" CommandParameter="Facebook"></TapGestureRecognizer>
                  </Image.GestureRecognizers>
                  </Image>
                  <Image Source="{cvt:ImageResource twitter.png}" BackgroundColor="Transparent"  HeightRequest="40" WidthRequest="40">
                  <Image.GestureRecognizers>
                  	<TapGestureRecognizer Command="{Binding ButtonTappedCommand}" CommandParameter="Twitter"></TapGestureRecognizer>
                  </Image.GestureRecognizers>
                  </Image>
              </StackLayout>
          </StackLayout>
    </Grid>
   </StackLayout>  
  </ContentPage.Content>
</common:BasePage>
Comment 4 Andrew 2015-03-13 09:13:05 UTC
It will fail if I change the Resource tag to ContentPage.Resources
Comment 5 Parmendra Kumar 2015-03-16 06:31:23 UTC
I have checked this issue with given code sample in comment #3 and i am getting custom namespace error, After removing these namespace I have build successfully but its throw exception on deploy. 

Exception: Unhandled Exception:
[mono] Xamarin.Forms.Xaml.XamlParseException: MarkupExtension not found for g:GlobalResource

Screencast: http://www.screencast.com/t/TVLw3jAnX

Please see the screencast and Application output and let me know If you getting same issue or
If I have missed anything. Could you Please provide us Application Output Log, IDE Log, BuildOutput Log, Sample project so the we can reproduce at our end.

Application Output: https://gist.github.com/Parmendrak/b4ed68ac8bf06aa85191
Build-output: https://gist.github.com/Parmendrak/48be66329ecfd78c4c56

Environment info:

=== Xamarin Studio ===

Version 5.8 (build 443)
Xcode 6.2 (6776)
Xamarin.iOS : 8.8.0.2 (Business Edition)
Xamarin.Android: 4.20.0.37 (Business Edition)
Xamarin.Mac : 1.10.0.21 (Business Edition)
Operating System OS X 10.9.4
Comment 6 Andrew 2015-03-16 09:00:15 UTC
"g" is not the issue.  the  <DataTemplate x:Key="AndroidItemTemplate">   and resource dictionary is.  I will build a sample project and post it.
Comment 7 Andrew 2015-03-16 12:52:49 UTC
Created attachment 10364 [details]
Resource Dictionary Bug Sample
Comment 8 Andrew 2015-03-16 12:53:14 UTC
added sample project that shows the issue.
Comment 9 Parmendra Kumar 2015-03-16 14:18:04 UTC
I have checked this issue and with attached sample project in comment #8 and I have getting same behavior mentioned in bug description.

Screencast: http://www.screencast.com/t/MUEwXKnfqd4

ApplicationOutput: https://gist.github.com/Parmendrak/dcb2cba9e99f9d8def0f
BuildOutput: https://gist.github.com/Parmendrak/280914b0d079ed600cae
IDELog: https://gist.github.com/Parmendrak/0e7463d2b48fce2f84ff

Environment info:

Xamarin.Forms: 1.4.0.6341 amd 1.4.1.6342-pre1

=== Xamarin Studio ===

Version 5.8 (build 443)
Installation UUID: 1a096c6f-0678-402e-89b2-a2c10f7e80e4
Runtime:
	Mono 3.12.1 ((detached/b7764aa)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312010000

=== Apple Developer Tools ===

Xcode 6.2 (6776)
Build 6C131e

=== Xamarin.iOS ===

Version: 8.10.0.90 (Business Edition)
Hash: 01afb49
Branch: master
Build date: 2015-03-15 01:52:46-0400

=== Xamarin.Android ===

Version: 4.20.0.37 (Business Edition)
Android SDK: /Users/360_macmini/Desktop/android-sdk-macosx
	Supported Android versions:
		2.1    (API level 7)
		2.2    (API level 8)
		2.3    (API level 10)
		3.1    (API level 12)
		4.0    (API level 14)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Xamarin.Mac ===

Version: 1.10.0.21 (Business Edition)

=== Build Information ===

Release ID: 508000443
Git revision: 73883239470cbe8e261c94d95f7c3d0452fd393b
Build date: 2015-03-10 07:22:51-04
Xamarin addins: a2ff7b617f09d9c45d8bbf3d010b5db0d7d36100

=== Operating System ===

Mac OS X 10.9.4
Darwin ShrutiMac.local 13.3.0 Darwin Kernel Version 13.3.0
    Tue Jun  3 21:27:35 PDT 2014
    root:xnu-2422.110.17~1/RELEASE_X86_64 x86_64
Comment 10 Jason Smith [MSFT] 2015-06-11 18:01:23 UTC
Should be fixed in 1.4.3 final
Comment 11 Parmendra Kumar 2015-06-19 09:45:32 UTC
I have checked this issue with xamarin.forms.1.4.3.6364-pre3 and its working fine at my end.

Hence closing this issue.

Environment info:
Xamarin Studio 5.9.3 (build 1)
Mono 4.0.1 ((detached/ed1d3ec)
GTK+ 2.24.23 (Raleigh theme)
Package version: 400010044
Xcode 6.2 (6776)
Xamarin.iOS : 8.10.1.64 (Enterprise Edition)
Xamarin.Android : 5.1.3.1 (Enterprise Edition)
Mac OS X 10.9.4
Comment 12 Ahmed Alejo 2015-09-25 07:20:57 UTC
the problem is most definately due to the following:

xmlns:g="clr-namespace:PSEA.Mobile.Data.Converters;assembly=PSEA.Mobile.Data"