We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

SfSchedule - Errors while trying to customize theme

Hi Curtis, 
  
Thanks for contacting Syncfusion support. 
  
We have analyzed the reported issue “TargetInvocationException occurs when trying to customize the default theme” and it is working fine from our side. we have ensured with customizing the default theme in simple sample and we have ensured the same with the attached sample on the UG documentation. We suspect that you didn’t set the Xamarin.Forms version as 3.0 or above as we haven mentioned in our UG documentation. Kindly check the Xamarin.Forms version. We have prepared sample for the same, please find the sample by the following link. 
  
Sample link: ScheduleTheming 
 
If the issue remains same even after updating to the Xamarin.Forms version as mentioned, kindly revert us by modifying the provided sample based on your scenario. It will be helpful for us to look on it and provide you appropriate solution. 
 
Regards,
Subburaj Pandian V 


3 Replies

CH Curtis Herrick January 21, 2019 09:43 AM UTC

I am trying to apply a custom theme to the SfSchedule Xamarin Forms control and am having issues trying to do so.

I am getting this exception upon loading my page:

        System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.


I updated my controls to 16.4.0.47 from 16.2.0.*, which (I believe) is necessary to have access to custom theme/style control.

My page with the SfSchedule control works fine, but only if I do not try to include any custom resource theme dictionary markup, etc in the XAML.

 If I comment this theme-related markup out, the page works fine in my app, but has default theming:

<syncTheme:SyncfusionThemeDictionary>
            <syncTheme:SyncfusionThemeDictionary.MergedDictionaries>
                <syncTheme:LightTheme x:Name="LightTheme" />
                <syncfusion:SfScheduleStyles />    <-------   This line in particular is the one that causes the reflection exception noted above.
                <ResourceDictionary>
                    <Color x:Key="SfScheduleMonthCellBackgroundColor">RedColor>
                ResourceDictionary>
            syncTheme:SyncfusionThemeDictionary.MergedDictionaries>
syncTheme:SyncfusionThemeDictionary>


If I try to use the resource content above, the page loads with a non-informative reflection exception.  I've tried picking apart the resource to see if any one part of it is causing the issue.  So far, only commenting the whole block out seems to get the page to not crash.

I do have a custom BaseView that all my pages inherit from, but I don't believe that is the problem.


The page is structured as follows:
             xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="com.XXX.MyApp.PhoneViews.CalendarPage"
             xmlns:local="clr-namespace:com.XXX.MyApp"
             xmlns:schedule="clr-namespace:Syncfusion.SfSchedule.XForms;assembly=Syncfusion.SfSchedule.XForms"
             xmlns:templates ="clr-namespace:com.XXX.MyApp.Views.PhoneTemplates"
             xmlns:c="clr-namespace:com.XXX.MyApp.Views.Common"
             xmlns:material="clr-namespace:com.XXX.MaterialForms;assembly=com.XXX.MaterialForms.Standard"
             Title="{Binding Title}"
             BackgroundImage="background.png"
             xmlns:syncfusion="clr-namespace:Syncfusion.SfSchedule.XForms;assembly=Syncfusion.SfSchedule.XForms"
             xmlns:syncTheme="clr-namespace:Syncfusion.XForms.Themes;assembly=Syncfusion.Core.XForms">

Not sure why, but upon editing this post, I can no longer copy/paste the complete XAML markup here.

What do I need to do or change to get this to work?

I'm trying to follow the example as shown here:
    https://help.syncfusion.com/xamarin/sfschedule/schedule-theme


One additional bit of info gathered:

01-18 13:41:03.385 E/AppCenterCrashes( 4994): System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeLoadException: Could not resolve type with token 01000103 (from typeref, class/assembly Syncfusion.SfSchedule.XForms.SfScheduleStyles, Syncfusion.SfSchedule.XForms, Version=16.4451.0.47, Culture=neutral, PublicKeyToken=null)


01-18 13:41:03.385 E/AppCenterCrashes( 4994): at com.XXX.MyApp.PhoneViews.CalendarPage..ctor () [0x00008] in C:\srclib\XXX\Mobile\Applications\MyApp\MyApp\MyApp\PhoneViews\Appointments\CalendarPage.xaml.cs:21



***  UPDATE  ***

After researching similar errors that others have experienced, I came to suspect that I had a difference in Nuget dependency versions within my Xamarin Forms solution.  To confirm this in Visual Studio, I right-clicked on the Solution in the solution explorer (not any of the child projects), and clicked "Manage Nuget Packages for Solution".  This lets you look through the various Nuget packages used within the solution - across its included projects.

Here I was able to see that some packages were not evenly updated across the solution's projects.  To fix this, you just simply need to pick the ones that are not consistent and update them for each project that is not inline with the others.

Makes sense, when the Xamarin Forms solution compiles and is running with a different version of a dependency, it may not map correctly at runtime, which gives the error "Could not resolve type with token 01000103" for example.

I've got it working now.  This thread can likely be closed.

--------------------------------------------

Note - I am not able to reply or reply with quote to your solution/response.  I am unable to get the checkbox for "I am not a robot" to respond or become checked.  You might want to check this over. - Curtis



CH Curtis Herrick replied to Subburaj Pandian Veluchamy January 21, 2019 09:56 AM UTC

Hi Curtis, 
  
Thanks for contacting Syncfusion support. 
  
We have analyzed the reported issue “TargetInvocationException occurs when trying to customize the default theme” and it is working fine from our side. we have ensured with customizing the default theme in simple sample and we have ensured the same with the attached sample on the UG documentation. We suspect that you didn’t set the Xamarin.Forms version as 3.0 or above as we haven mentioned in our UG documentation. Kindly check the Xamarin.Forms version. We have prepared sample for the same, please find the sample by the following link. 
  
Sample link: ScheduleTheming 
 
If the issue remains same even after updating to the Xamarin.Forms version as mentioned, kindly revert us by modifying the provided sample based on your scenario. It will be helpful for us to look on it and provide you appropriate solution. 
 
Regards,
Subburaj Pandian V 


After researching similar errors that others have experienced, I came to suspect that I had a difference in Nuget dependency versions within my Xamarin Forms solution.  To confirm this in Visual Studio, I right-clicked on the Solution in the solution explorer (not any of the child projects), and clicked "Manage Nuget Packages for Solution".  This lets you look through the various Nuget packages used within the solution - across its included projects.

Here I was able to see that some packages were not evenly updated across the solution's projects.  To fix this, you just simply need to pick the ones that are not consistent and update them for each project that is not inline with the others.

Makes sense, when the Xamarin Forms solution compiles and is running with a different version of a dependency, the interpretted type may not map correctly at runtime, which gives the error "Could not resolve type with token 01000103" for example.

I've got it working now.  This thread can likely be closed.

--------------------------------------------

Note - It was difficult to reply or reply with quote to your solution/response.  After some experimentation, I found that I had to rapidly/repeatedly click the "I am not a robot" checkbox (like 20 times) to get it to respond or become checked.  You might want to look into this. 

Thanks! 
- Curtis



SP Subburaj Pandian Veluchamy Syncfusion Team January 22, 2019 10:31 AM UTC

Hi Curtis, 
 
Thank you for the update. We are happy that the given solution meets your requirement. 
 
Regarding Website related query: 
 
Sorry for the inconvenience caused.  
 
We have checked and we are unable to reproduce the issue you have reported “I am not a robot” not responding. Can you please share following details to replicate the issue? 
  
·       Browser details. 
·       Browser console error details. 
 
It will more helpful for us to check on it and resolve the reported issue as early as possible. 
 
Regards,
Subburaj Pandian V  
 


Loader.
Live Chat Icon For mobile
Up arrow icon