Blazor and code-behind files in Oxygene

Hello,
I only have, currently, the Oxygene compiler, but I would like to know the answer to this question:
If I have Remobjects C# and Oxygene, is it possible to have a Blazor application with the code behind files in Oxygene?

We don’t currently have any official support for Blazor. At all. It’s also still in “Preview 1” mode, so I’m not sure if its worth us investing much in supporting it yet.

If you have Oxygene and RemObjects C# (i.e. full Elements), you can use Razor and .cshtml files. Whether and how well that support works for Blazor at this stage is up fro grabs.

The alternative to Blazor I am planning to use is WebAssembly for client-side code combined with WebServices for the server-side code.

1 Like

Blazor server is supported on .NET Core 3.0. It’s Blazor client that’s still in preview.

Then maybe I’m confused tat Blazor means. I tough Razor was server-side .cshtml (that works), and Blazor is the WebAssembly (ie by definition, client) part?

Right for Razor that is the language used in .cshtml.

Blazor exists in two flavours:

  • Server side, where the server does all the work and returns the changes in the DOM to the client using a SignalR connection.
  • Client side: this is the web assembly version.

For more information: ASP.NET Core Blazor hosting models | Microsoft Learn

Gotcha. I’d expect server-side should “just work” (but feedback appreciated; if you find any issues I’ll be happy to look into fixing them ASAP).

client-side might also just work, or might not (though usually, these days, .NET ha so many special hacks for everything that it probably won’t, out of the box). If you give it a try, id love to hear now far it gets and what fails, as I’ll be looking at supporting this eventually, too, but more long short term.

It works almost with a C# main project in the solution. The only problem I have is https://talk.remobjects.com/t/problem-publishing-a-blazor-client-application-with-oxygene-assemblies/21893/17

But I would like to write the code-behind files in Oxygene instead of C#, so my question in this thread (I cannot test because I don’t have a licence of RemObjects C#.)

You can write the .cshml.pas in Oxygene; the .cshtml itself needs to be C#, and we don’t/won’t support any other languages; this should work with the 30-day trial for C#, fwiw.

How can I activate the 30-day trial for C#, to have a look, as I’m registered only for Oxygene?

It should activate itself the first time you use C#.

When I create a Blazor client application, VS creates a .csproj file that is tied to Visual C# and there is no way to add an Oxygene file to it.

The default .csproj file is:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netstandard2.1</TargetFramework>
    <RazorLangVersion>3.0</RazorLangVersion>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="3.2.0-rc1.20223.4" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Build" Version="3.2.0-rc1.20223.4" PrivateAssets="all" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="3.2.0-rc1.20223.4" PrivateAssets="all" />
    <PackageReference Include="System.Net.Http.Json" Version="3.2.0-rc1.20217.1" />
  </ItemGroup>

</Project>

Obviously.

I did mention that we don’t officially support Blazor yet, right? That includes not having a project template for it; you will need to sort this our yourself start with (for example) a project created with the Razor template, and make the necessary adjustments/add the necessary files to make it match what VC# does.

Ok, that should match what you get when you create a new Oxygene ASP.NET project from template. Do that, add the references, add the same (kind of) files that the VC# project has (and convert the .cs ones to .pas, as you see fit), and off you go.

What is the updated status of RemObjects/Oxygene support for Blazor? Is it ready for production?

We want to use Blazor (WebAssembly) with VB.net, do you have any infos about that?
Blazor is the next “big thing” (meant positive)

Dear Marcus.

Blazor is still a Microsoft C# only technology, as the support for it is not in the language but in the compiler. And the only compiler that has the support at this moment is the Microsoft Roslyn C# compiler. So Blazor won’t be supported any time soon as this means that Remobject has to build all Xamarin support first, and that is an awful lot of work.

But Blazor is not the “Next big thing” - that’s only Microsoft marketing.
Web-Assmbly IS the next big thing, and Blazor is just one of the possibilities to create Web-Assemblies.

So, Blazor is just Microsoft’s way to do Web-Assembly.
And if you insist doing Web-Assembly the Microsoft way, the only choice you have is using Microsoft C#. No vendor, platform or language will support it.

But if you want to use Elements (any language), you can use the RemObjects implementation of Web-Assembly. Just select the template Web-Assembly (code behind) and you can build the Web-Assembly code in Mercury or any other language.

With this template you can use the standard VB Handles clause to handle Html events (for other elements languages: just the normal event handler wiring, for Mercury AddHandler and RemoveHandler can also be used).
The code needed to access to the elements in the Html is generated on compile, so you can use the Id name of the Html elements as variable names in the code.
All access to DOM objects is strict and has CC is available for them to enable you to program fast; it’s just like you are programming WinForms.

When you need server access from the WebAssembly, use the Browser.newXmlHttpRequest object, which gives you asynchronous access to any http(s) server resource you might need.

2 Likes