Sometimes strange things happen in your app, it could be that a problem deep in Xamarin.Forms is the cause. Here’s a very condensed, simple way to have your App point to the Xamarin.Forms code so that errors can be caught and causes more easily determined.
Note: Breaking changes in 3.5.0, see below
This is heavily based on the guide at Xamarin, but simplified and condensed into a path I found that works.
For Windows – Visual Studio 2017/2019
Get the Code:
Install the GitHub Desktop application.
GOTCHA: If you’ve tried before delete any repo and start fresh.
Run it and choose the opportunity to Clone a repository from a Url. Enter the URL https://github.com/xamarin/Xamarin.Forms . I put my repos into E:\GitHub
Build the Code in Visual Studio
Turn off Resharper if you have it, it’ll slow you down really badly. You can re-enable it later.
Go to your repo, in my case E:\GitHub and open Xamarin.Forms.sln
Switch to the version branch you want to debug, like 3.4.0
When it loads in Visual Studio, Switch to Any CPU, then Build the Solution. This can take 5 minutes!! You will see errors probably. You should be able to ignore them.
GOTCHA!! It must be Any CPU
Close Visual Studio
Build the NuGet
Add a System Environment variable to where you have NuGet.exe. I put mine in e:\GitHub\
GOTCHA!! Add a \ to the end of the folder
Open a Command Prompt and go to the main folder in the repo. In my case E:\GitHub\Xamarin.Forms
Run the batch file .create-nuget.bat all
GOTCHA – Did you forget the all parameter?
When done, there will be a new file named something like Xamarin.Forms.9.9.0.nupkg in the .nuspec folder
Copy this file to a new Folder which will serve as your NuGet folder. I use E:\NuGetServer
Open your app, then add a new Nuget server pointing to that folder.
Now update your Xamarin Forms Package to point to your NuGet folder. Notice the version is 9.9.0.
GOTCHA!! Manually delete all bin and obj folders and restart Visual Studio. I’ve had strange things happen when I switch Xamarin Forms versions if I don’t.
Run your app!
Now when there is an error, Visual Studio will step into the Xamarin.Forms code
Changes for version 3.5.0
Switching to Cake and powershell https://github.com/xamarin/Xamarin.Forms/pull/5074