Your project is now referencing a version of OpenSilver that is newer and contains many improvements, but has some breaking changes which require migration of your project. To do that, simply follow the easy steps described below (or, alternatively, create a new project using the latest VSIX which contains updated project templates).
1.1. Find <TargetFramework>netstandard2.0</TargetFramework> and replace it with <TargetFramework>netstandard2.1</TargetFramework>
1.2. Find the block <PropertyGroup Label=”Globals”> and add the following code inside the block:
<NoXamlPreprocessor>True</NoXamlPreprocessor>
<OpenSilverType>2</OpenSilverType>
1.3. Find the “PackageReference” string and add the following additional package references:
<PackageReference Include=”Microsoft.AspNetCore.Components.WebAssembly” Version=”3.2.0″ />
<PackageReference Include=”Microsoft.AspNetCore.Components.WebAssembly.Build” Version=”3.2.0″ />
<PackageReference Include=”Microsoft.AspNetCore.Components.WebAssembly.DevServer” Version=”3.2.0″ />
Program.RunApplication();
“inspectUri”: “{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}”,
using System;
using System.Net.Http;
using System.Threading.Tasks;
using System.Windows;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.DependencyInjection;
using DotNetForHtml5;
namespace YOUR_APP_NAMESPACE.Browser
{
public class Program
{
public async static Task Main(string[] args)
{
Cshtml5Initializer.Initialize();
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add("app");
builder.Services.AddTransient(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
var host = builder.Build();
await host.RunAsync();
}
public static void RunApplication()
{
Application.RunApplication(() =>
{
var app = new YOUR_APP_NAMESPACE.App();
});
}
}
}
When you have completed the steps above, restore the NuGet packages (by right-clicking on the solution in the Solution Explorer and clicking “Restore NuGet Packages”) and rebuild the solution.
Note: alternatively to the instructions above, you can create a new project using the latest VSIX which contains updated project templates.
If you have any questions, please contact us at: