Xamarin Forms Crashing System.Reflection.TargetInvocationException

CostasAletrariCostasAletrari USMember ✭✭
edited June 2018 in Xamarin.Forms

Hello, I'm currently having an issue while launching a xamarin forms app which constantly crashes with this error:

FATAL UNHANDLED EXCEPTION: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidCastException: Specified cast is not valid.

I've managed to pin point that the error occurs while trying to get the Android Custom Font. (On Platform Android)

    <On Platform="Android" Value="CenturyGothic.ttf#Century-Gothic-Regular"/>

I had not made any changes to the app source code for a while but have recently upgraded to VS 15.7

I've tried deleteing the obj and bin folders in PCL and Android, Clean, Build, Deploy but still have the same issue

I've deleted the font TTF in the Android project and re added making sure that the properties for the TTF are AndroidAsset. With once again a clean and build, deploy and again same error.

I tried a File -> New project which creates a xamarin forms 3.0 app, copied the code over for a test and it works. We are currently using XF 2.4.0

I've also come accross this error

[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Forms.Build.Tasks.XamlG", "")]
private void InitializeComponent() {
global::Xamarin.Forms.Xaml.Extensions.LoadFromXaml(this, typeof(MainPage));

Any suggestions, Thank you.


  • RobertAuerRobertAuer USMember ✭✭

    I am also seeing the same thing. The code I ran before upgrading to VS 15.7 worked fine. But after the update (yesterday) it no longer functions.


  • CostasAletrariCostasAletrari USMember ✭✭

    I ended up have to create a new project and moving all the code across to the new project file, too much time went into trying to solve a simple task

Sign In or Register to comment.