The version of OpenSilver that you are referencing (2.0 or newer) requires the migration of your project.
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. Open the .CSPROJ of the project that has the “.Browser” suffix (to do so, you can just double-click on the project name from the Solution Explorer), and make the following changes:
Find <OpenSilverType>4</OpenSilverType> and replace it with <OpenSilverType>5</OpenSilverType>

2. Make sure that all the packages referenced by your projects have the same version, as shown in the screenshot below.

3. In the project which has the “.Browser” suffix, replace the contents of the file Interop/UnmarshalledJavaScriptExecutionHandler.cs with the following code:
(Note: you need to replace <PUT YOUR APP NAMESPACE HERE> with the namespace of your app)
using DotNetForHtml5;
using Microsoft.JSInterop;
using Microsoft.JSInterop.WebAssembly;
namespace .Browser.Interop
{
public class UnmarshalledJavaScriptExecutionHandler : IWebAssemblyExecutionHandler
{
private const string MethodName = "callJSUnmarshalled_v2";
private readonly WebAssemblyJSRuntime _runtime;
public UnmarshalledJavaScriptExecutionHandler(IJSRuntime runtime)
{
_runtime = runtime as WebAssemblyJSRuntime;
}
public void ExecuteJavaScript(string javaScriptToExecute)
{
_runtime.InvokeUnmarshalled(MethodName, javaScriptToExecute);
}
public object ExecuteJavaScriptWithResult(string javaScriptToExecute)
{
return _runtime.InvokeUnmarshalled(MethodName, javaScriptToExecute);
}
public TResult InvokeUnmarshalled(string identifier, T0 arg0)
{
return _runtime.InvokeUnmarshalled(identifier, arg0);
}
public TResult InvokeUnmarshalled(string identifier, T0 arg0, T1 arg1)
{
return _runtime.InvokeUnmarshalled(identifier, arg0, arg1);
}
public TResult InvokeUnmarshalled(string identifier, T0 arg0, T1 arg1, T2 arg2)
{
return _runtime.InvokeUnmarshalled(identifier, arg0, arg1, arg2);
}
}
}
4. Restart all your instances of Visual Studio.
New VSIX (optional):
We encourage you to download the updated Visual Studio Extension (.VSIX), which includes many new features, such as:
- New project templates for OpenSilver 2.0
- A live XAML Preview, which lets you see the GUI of your app at design-time
- Project templates for VB.NET
- New “Business Application” project template, containing a client/server solution powered by RIA Services (see documentation and tutorial)
Some of those new features are shown on the OpenSilver 2.0 Announcement page.
Need help?
If you have any questions, please contact us :