BlazorMobile.Common 3.0.4-preview7.19365.7

This is a prerelease version of BlazorMobile.Common.
There is a newer version of this package available.
See the version list below for details.
Install-Package BlazorMobile.Common -Version 3.0.4-preview7.19365.7
dotnet add package BlazorMobile.Common --version 3.0.4-preview7.19365.7
<PackageReference Include="BlazorMobile.Common" Version="3.0.4-preview7.19365.7" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BlazorMobile.Common --version 3.0.4-preview7.19365.7
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: BlazorMobile.Common, 3.0.4-preview7.19365.7"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install BlazorMobile.Common as a Cake Addin
#addin nuget:?package=BlazorMobile.Common&version=3.0.4-preview7.19365.7&prerelease

// Install BlazorMobile.Common as a Cake Tool
#tool nuget:?package=BlazorMobile.Common&version=3.0.4-preview7.19365.7&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

See documentation on BlazorMobile project page


BlazorMobile 0.8.0 to 3.0.3-preview7.19365.7

In your Blazor project, edit your *.csproj file:

  • Remove the BlazorMobile.Common PackageReference
  • Remove the manual PostBuild event, that look like this:
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
    <Exec Command="rm $(ProjectDir)\BuildTools\artifacts\ &gt;nul 2&gt;&amp;1&#xD;&#xA;$(ProjectDir)\BuildTools\7za.exe a $(ProjectDir)\BuildTools\artifacts\ $(ProjectDir)wwwroot\* -mx1 -tzip&#xD;&#xA;$(ProjectDir)\BuildTools\7za.exe a $(ProjectDir)\BuildTools\artifacts\ $(ProjectDir)$(OutputPath)dist\* -mx1 -tzip" />
  • In this same project file, add a PackageReference to BlazorMobile.Build and BlazorMobile.Web. This should look like this:
  <PackageReference Include="BlazorMobile.Build" Version="3.0.3-preview7.19365.7" />
  <PackageReference Include="BlazorMobile.Web" Version="3.0.3-preview7.19365.7" />
  <PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.0.0-preview7.19365.7" />
  <PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.0.0-preview7.19365.7" PrivateAssets="all" />
  <PackageReference Include="Microsoft.AspNetCore.Blazor.DevServer" Version="3.0.0-preview7.19365.7" />
  • In all of your projects, update any reference of BlazorMobile or BlazorMobile.Common to the 3.0.3-preview7.19365.7 version.

In your Startup.cs file, in Configure, replace:

public void Configure(IComponentsApplicationBuilder app)

    BlazorWebViewService.Init(app, "blazorXamarin", (bool success) =>
        Console.WriteLine($"Initialization success: {success}");
        Console.WriteLine("Device is: " + Device.RuntimePlatform);


public void Configure(IComponentsApplicationBuilder app)
    #if DEBUG

    //Only if you want to test WebAssembly with remote debugging from a dev machine
    BlazorService.EnableClientToDeviceRemoteDebugging("", 8888);


    BlazorService.Init(app, (bool success) =>
        Console.WriteLine($"Initialization success: {success}");
        Console.WriteLine("Device is: " + Device.RuntimePlatform);


Actually, change the onSuccess delegate to anything you want. But notice the MobileApp instead of App component.

You should create your own component inherited from App. Create a MobileApp.cs file in your Blazor project and copy/paste this:

using BlazorMobile.Common.Components;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.RenderTree;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace BlazorMobile.Sample.Blazor
    public class MobileApp : App
        protected override void BuildRenderTree(RenderTreeBuilder builder)
            builder.OpenElement(0, nameof(BlazorMobileComponent));
            builder.OpenComponent(1, typeof(BlazorMobileComponent));


Of course, replace the given namespaces by the one used by your own project.

  • In your index.html from your Blazor project, you can safely remove the blazorXamarin tag.
  • If you intent to use the server-mode to debug (see related documentation), you can also update the blazor script tag. In the current sample, index.html look like this:
<!DOCTYPE html>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <base href="/" />
    <link href="css/bootstrap/bootstrap.min.css" rel="stylesheet" />
    <link href="css/site.css" rel="stylesheet" />
    <script type="text/javascript" src="js/blazor.polyfill.js"></script>
    <script id="blazorMode"></script>
        document.getElementById("blazorMode").src ="mode=server") ? "_framework/blazor.server.js" : "_framework/blazor.webassembly.js";

See the documentation, about how to switch from WASM to .NET Core debugging if needed.

  • Update your RegisterAppStreamResolver code if needed. See the linking Blazor to Xamarin section for this.
  • Add missing additionnals project if needed from samples, to your project.

New projects are:

  • BlazorMobile.Sample.Blazor.Server, for testing your Blazor app with the .NET Core runtime
  • BlazorMobile.Sample.UWP, for deploying your Blazor app to UWP (Windows 10).

BlazorMobile 3.0.3-preview7.19365.7 to 3.0.4-preview7.19365.7

In your Xamarin shared project, like BlazorMobile.Sample sample project you should:

  • Inherit from BlazorApplication instead of Application in App.xaml.cs
using BlazorMobile.Components;
using BlazorMobile.Services;
using System;
using Xamarin.Forms;

namespace BlazorMobile.Sample
    public partial class App : BlazorApplication
        public App()
            ...Your code...
  • Inherit from BlazorApplication instead of Application in App.xaml too. Your code should look like this:
<?xml version="1.0" encoding="utf-8" ?>
  • You should remove any WebApplicationFactory.StartWebServer and WebApplicationFactory.StopWebServer reference in your App.xaml.cs, as they are now internals and managed by the BlazorApplication class. You can safely remove theses lines:
protected override void OnStart()

protected override void OnSleep()

protected override void OnResume()

NOTE: WebApplicationFactory.SetHttpPort is not mandatory anymore as if the app fail to bind on your specific port, it will fallback on another available port. But you can still use it for your specific needs and in order to assign a fixed port for remote debugging sessions.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on BlazorMobile.Common:

Package Downloads

BlazorMobile: Launch Blazor as a mobile application on iOS, Android & UWP, with native communication support. Support iOS 12+, Android 4.4 >= and UWP. Install this package on your shared Xamarin.Forms app project.


This NuGet package intended for the Blazor application side of the BlazorMobile package.


This package allow BlazorMobile to be compatible with an ElectronNET server-side Blazor application, so you can use the same project structure and interoping calls either on Mobile (BlazorMobile) and Desktop (ElectronNET)

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on BlazorMobile.Common:

Repository Stars
Create full C# driven hybrid-apps for iOS, Android, UWP & Desktop with Blazor!

Updated NuGet package to be based on Blazor 3.0.0-preview7.19365.7. Migrated any Blazor dependencies in BlazorMobile.Web