Search code examples
c#xamarin.formsxlabs

XLabs HybridWebView: Could not load file or assembly XLabs.Serialization


I'm trying to set up HybridWevView for my Xamarin.Forms app. This is how I configured it:

  1. Install XLab.Forms (and some connected libraries) in NugetPackage
  2. Copy-paste code from this sample page just to see if it works

Unfortunatly this is what I see when I try to run it:

An exception of type 'System.IO.FileNotFoundException' occurred in TestApp.dll but was not handled in user code

Additional information: Could not load file or assembly 'XLabs.Serialization, Version=2.0.5782.12218, Culture=neutral, PublicKeyToken=d65109b36e5040e4' or one of its dependencies. The system cannot find the file specified.

Error appears after launching Windows 10 app (no errors during build). Visual Studio shows this message exactly at this line

Have I configured eveything correctly?


Solution

  • For UWP application you would have to install the Pre version. On the Pre the problem would be that none of the Serialization packages seem to work with UWP. If you test with Windows 8.1 project then you still need to setup a JSON serializer. The next release should have a default serializer but the current release does not so you would need to install XLabs.Serialization.JSON and put this code in the app start:

            if (!Resolver.IsSet)
            {
                var container = new SimpleContainer();
    
                container.Register<IJsonSerializer, XLabs.Serialization.JsonNET.JsonSerializer>();
    
                Resolver.SetResolver(container.GetResolver());
            }