Error building VCL webassembly sample project

I’m trying to build the VCL webassembly sample project in Elements .2331 but I’m getting an error:

“C:\Program Files (x86)\RemObjects Software\Elements\Bin\EBuild.exe” C:\devdata\water\webasm-vcl-test-oxy\Sample.sln --logger:fire --configuration:Debug --verbosity:normal --xml:C:\devdata\water\webasm-vcl-test-oxy\obj\Sample.water.xml --build --setting:TreatFixableErrorsAsWarnings=True
RemObjects EBuild. An open source build engine for Elements and beyond.
Copyright RemObjects Software 2016-2018. All Rights Reserved. Created by marc hoffman.
Version 10.0.0.2331 (develop) built on talax, 20180928-142533. Commit 8e4eb02.

No exact WebAssembly SDK version was specified for target ‘WebAssembly 1.0’, using ‘WebAssembly 1.0’.
Reference ‘Elements’ was resolved to ‘C:\Program Files (x86)\RemObjects Software\Elements\Island\Reference Libraries\WebAssembly\wasm32\Elements.fx’ for target ‘Island-WebAssembly’.
Reference ‘Elements’ was resolved to ‘C:\Program Files (x86)\RemObjects Software\Elements\Island\Reference Libraries\WebAssembly\wasm32\Elements.fx’ for target ‘Island-WebAssembly’ (wasm32).
Reference ‘Island’ was resolved to ‘C:\Program Files (x86)\RemObjects Software\Elements\Island\Reference Libraries\WebAssembly\wasm32\Island.fx’ for target ‘Island-WebAssembly’.
Reference ‘Island’ was resolved to ‘C:\Program Files (x86)\RemObjects Software\Elements\Island\Reference Libraries\WebAssembly\wasm32\Island.fx’ for target ‘Island-WebAssembly’ (wasm32).
Reference ‘Delphi’ was resolved to ‘C:\Program Files (x86)\RemObjects Software\Elements\Island\Reference Libraries\WebAssembly\wasm32\Delphi.fx’ for target ‘Island-WebAssembly’.
Reference ‘Delphi’ was resolved to ‘C:\Program Files (x86)\RemObjects Software\Elements\Island\Reference Libraries\WebAssembly\wasm32\Delphi.fx’ for target ‘Island-WebAssembly’ (wasm32).
RemObjects Elements (Oxygene, C#, Swift and Java) Compiler for .NET, Cocoa, Java and Island.
Version 10.0.0.2331 (develop) built on talax, 20180928-142533. Commit 8e4eb02.
Copyright 2003-2018 RemObjects Software, LLC. All rights reserved.

Source file: C:\devdata\water\webasm-vcl-test-oxy\Unit2.pas
Source file: C:\devdata\water\webasm-vcl-test-oxy\Program.pas
Resource file: C:\Users\Chris\AppData\Local\RemObjects Software\EBuild\Obj\Sample-3078B350CF7BA8403BCC941914580BA6C8C9E074\Debug\Island-WebAssembly\res\Unit2.dfm
Reference: C:\Program Files (x86)\RemObjects Software\Elements\Island\Reference Libraries\WebAssembly\wasm32\Delphi.fx
Reference: C:\Program Files (x86)\RemObjects Software\Elements\Island\Reference Libraries\WebAssembly\wasm32\Elements.fx
Reference: C:\Program Files (x86)\RemObjects Software\Elements\Island\Reference Libraries\WebAssembly\wasm32\Island.fx
E: Error while loading unmanaged resource file “C:\Users\Chris\AppData\Local\RemObjects Software\EBuild\Obj\Sample-3078B350CF7BA8403BCC941914580BA6C8C9E074\Debug\Island-WebAssembly\res\Unit2.dfm”
Project ‘Sample’ failed to build.
Solution ‘Sample’ failed to build all projects.

I first tried to make my own test project in C# and was getting this same error, so I assumed I was doing something wrong. I then downloaded the Oxygene sample from the RemObjects Git repo, but I get this same error in both cases.

Do I need a newer build of Elements for this to work?

any chance you can send us the project? also, what’s your login name for RemObjects.com — i’d like to send you a newer version, last friday’s build 2335, so you can see if the issue persist for you.

Fwiw, I tried this sample https://github.com/remobjects/ElementsSamples/tree/master/Oxygene/Island/Delphi%20VCL/Sample-Wasm and it compiles fine for me in .2335.

Can you zip and attach the file “C:\Users\Chris\AppData\Local\RemObjects Software\EBuild\Obj\Sample-3078B350CF7BA8403BCC941914580BA6C8C9E074\Debug\Island-WebAssembly\res\Unit2.dfm”?

I’ve uploaded .2335 to your Personal Downloads page, jic.

I have upgraded to .2335 and am now running a registered version of Elements.

I have attached 4 files:

Sample.zip is the sample Oxygene project that won’t compile
Unit2.zip is the Unit2.dfm file from that long path location shown in the error text

I have also done a rough conversion of the Sample-Wasm project into C#. It seems that since I only have a license for C# that the ‘Paste & Convert Delphi Codee’ no longer is an option so I had to do it by hand. Might not even be a correct translation, but because the build fails I haven’t been able to test it.

Note ‘Codee’ in my previous paragraph… yes there is a typo there in Water. Thought you might want to know.

Anyway, I get the same error in the C# project.

SampleCs.zip is the C# version of the project
Unit2CS.zip is the Unit2.dfm referenced in the error message.

Sample.zip (3.2 KB)
SampleCs.zip (2.8 KB)
Unit2.zip (146 Bytes)
Unit2Cs.zip (146 Bytes)

Not to sidetrack the discussion but in the new .2335 build I get this error screen when right-clicking on References -> Add Reference:

Object reference not set to an instance of an object. at RemObjects.Fire.App.AddReferenceWindowController.setup() at RemObjects.Fire.App.AddReferenceWindowController..ctor(Project project) at RemObjects.Fire.App.SolutionDocumentWindowController.solutionAsksToShowAddReferenceSheet(Notification notification) at RemObjects.Elements.RTL.BroadcastManager.<>c__DisplayClass4.b__0() at RemObjects.Elements.RTL.BroadcastManager.submitBroadcast____object__data__syncToMainThread(String broadcast, Object object, Dictionary`2 data, Boolean syncToMainThread) at RemObjects.Fire.ProjectSystem.ReferencesFolder.addReference(Object sender) at RemObjects.Fire.CrossPlatform.MenuItem.onClick(Object sender, RoutedEventArgs e) at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args) at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e) at System.Windows.Controls.MenuItem.InvokeClickAfterRender(Object arg) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

I get a similar, but different error when going through the menu: Project -> Manage Reference:

Object reference not set to an instance of an object. at RemObjects.Fire.App.AddReferenceWindowController.setup() at RemObjects.Fire.App.AddReferenceWindowController..ctor(Project project) at RemObjects.Fire.App.SolutionDocumentWindowController.addReferencesToProject(Object sender) at RemObjects.Fire.App.SolutionDocumentWindowController.b__0(Object sender) at RemObjects.Water.UITools.RelayCommand.Execute(Object parameter) at MS.Internal.Commands.CommandHelpers.CriticalExecuteCommandSource(ICommandSource commandSource, Boolean userInitiated) at System.Windows.Controls.MenuItem.InvokeClickAfterRender(Object arg) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

Adding references manually to the .sln file seems to work ok.

In regards to the adding references error above, I have a little more info.

If I create a new solution using the Echos templates, I don’t get the errors. I do get the errors after creating new solutions using the Island templates.

I get similar errors creating new projects using Cooper templates, but not Toffee templates.

I didn’t try every template for every platform, but the ones I did try seemed to follow this pattern.

I also tried opening a couple Island projects from the RemObjects Samples folders. I get the errors with them to. So it probably isn’t a creating-a-new-solution-from-a-template problem.

Edit:
One more data point - I uninstalled .2335 and went back to .2331 and I don’t get the ‘Add Reference’ errors. But in both versions I am still getting the error when building the VCL sample projects (the real reason for this thread).

that add reference issue was a regression in 2335 and is fixed for today’s update. will get back to the rest later…

Curious. That one fails here too. but the one on GitHub works, and oddly they are exactly the same… I’ll log an issue to have Carlo check into this.

FWIW Converting Delphi code was only ever supported to Oxygene, not to the other languages — because the Delphi convert does not actually translate the file to a different language, it just makes slight adjustments to the Pascal syntax. We don’t currently support converting form Pascal to C#, Swift or Java, sorry :(.

Fixed, thanx.

No, the problem seems to be entirely isolated to the .dfm file, and unrelated to the actual code. Something seems to go wrong in the conversion to a binary resource.

Thanks, logged as bugs://81259

bugs://81259 got closed with status fixed.

Fixed. Problem was that editing the .dfm file in Water added a UTF-8 header to the .dfm (as it should, but which the diff didn’t show ;), and the DFM converter failed on that. the latter part is fixed now.

Awesome! Thanks.

Is there a way to download the latest build(s), or do I just wait until the next beta download is up on your site?

We’ll have a new build out for everyone later today. As a workaround, just restore the original .dfm fine from the sample or from github, and don’t edit it in Water.

The new beta version (.2337) takes care of the .dfm problem, but I’m having a different problem now. I realize it is beta, so no real expectations.

When I create a new project with the ‘Island Module (WebAssembly)’ template and just leave it blank (as created), the project won’t run in my browser (Chrome). The same project compiled under .2331 runs ok.

Here is the error info from the Chrome debugger:

WebAssembly file Module.wasm has been loaded.
RemObjectsElements.js:277 HelloWorld
wasm-014cb3d6-1108:63 Uncaught (in promise) RuntimeError: invalid index into function table
at .Lmi_s6_Equalsns (wasm-function[1108]:135)
at .Lms_sc_op__Equalitynsns (wasm-function[399]:68)
at .Lmi_t31_RemObjects_d_Elements_d_System_d_EcmaScriptObject6_Invokensni32na_o (wasm-function[4940]:15)
at .L_intf__rtti_t31_RemObjects_d_Elements_d_System_d_EcmaScriptObject_vmthelper2 (wasm-function[4963]:106)
at .Lms_t2f_RemObjects_d_Elements_d_System_d_DynamicHelpers6_Invokenonsni32na_o (wasm-function[3845]:219)
at mi_t10_Module_d_Programa_HelloWorld (wasm-function[5610]:660)
at imp.env.__island_invoke (https://www.notepage.net/download/dev/wa/wasm/RemObjectsElements.js:443:38)
at .Lms_t2c_RemObjects_d_Elements_d_System_d_WebAssemblyc_InvokeMethodnp_vna_o (wasm-function[4635]:25)
at .Lmi_t2b_RemObjects_d_Elements_d_System_d_MethodInfo6_Invokenona_o (wasm-function[3823]:43)
at .Lmi_tnt2c_RemObjects_d_Elements_d_System_d_WebAssembly18__l__g_c____DisplayClass117__l_GetProxyFor_g_b____2nt31_RemObjects_d_Elements_d_System_d_EcmaScriptObject (wasm-function[4989]:158)
.Lmi_s6_Equalsns @ wasm-014cb3d6-1108:63
.Lms_sc_op__Equalitynsns @ wasm-014cb3d6-399:38
.Lmi_t31_RemObjects_d_Elements_d_System_d_EcmaScriptObject6_Invokensni32na_o @ wasm-014cb3d6-4940:9
.L_intf__rtti_t31_RemObjects_d_Elements_d_System_d_EcmaScriptObject_vmthelper2 @ wasm-014cb3d6-4963:120
.Lms_t2f_RemObjects_d_Elements_d_System_d_DynamicHelpers6_Invokenonsni32na_o @ wasm-014cb3d6-3845:136
mi_t10_Module_d_Programa_HelloWorld @ wasm-014cb3d6-5610:291
imp.env.__island_invoke @ RemObjectsElements.js:443
.Lms_t2c_RemObjects_d_Elements_d_System_d_WebAssemblyc_InvokeMethodnp_vna_o @ wasm-014cb3d6-4635:302
.Lmi_t2b_RemObjects_d_Elements_d_System_d_MethodInfo6_Invokenona_o @ wasm-014cb3d6-3823:1089
.Lmi_tnt2c_RemObjects_d_Elements_d_System_d_WebAssembly18__l__g_c____DisplayClass117__l_GetProxyFor_g_b____2nt31_RemObjects_d_Elements_d_System_d_EcmaScriptObject @ wasm-014cb3d6-4989:429
.Lmi_t34_RemObjects_d_Elements_d_System_d_WebAssemblyDelegate6_Invokent31_RemObjects_d_Elements_d_System_d_EcmaScriptObject @ wasm-014cb3d6-4975:33
__island_call_delegate @ wasm-014cb3d6-5018:18
res @ RemObjectsElements.js:246
(anonymous) @ (index):14
Promise.then (async)
(anonymous) @ (index):11

I have attached the /wasm folder from each build.

Thanks

2331.zip (1012.2 KB)
2337.zip (1.1 MB)

Thanks, logged as bugs://81263

bugs://81263 got closed with status fixed.

The errors are gone now :slight_smile:

However, I’ve been trying for a few days now to build a sample program in C# that has minimal functionality.

At the moment I’m just trying to show a single button on a form.

I’m 90% sure I’m doing something wrong, but I’m having a hard time wrapping my head around how to implement this in C#.

Any help would be greatly appreciated.

Program.cs

using RemObjects.Elements.RTL.Delphi;
using RemObjects.Elements.RTL.Delphi.VCL;

namespace VclRoTest
{
    [Export]
    public class Program
    {
        public TForm1 Form1;
        
        public void Main()
        {
            TForm1 Form1 = new TForm1(null);
            TApplication application = new TApplication(null);
            application.Initialize();
            application.CreateForm(typeOf(Form1), ref Form1);
            application.Run();
        }
    }
}

Form1.cs

using RemObjects.Elements.RTL.Delphi;
using RemObjects.Elements.RTL.Delphi.VCL;

namespace VclRoTest
{

    public class TForm1 : TForm
    {
        public TButton Button1;
        
        private void Button1Click(TObject sender)
        {
            
        }
    }
}

Form1.dfm

object Form1: TForm1
 Left = 0
 Top = 0
 Caption = 'Test'
 ClientHeight = 299
 ClientWidth = 635
 Color = clBtnFace
 Font.Charset = DEFAULT_CHARSET
 Font.Color = clWindowText
 Font.Height = -11
 Font.Name = 'Tahoma'
 Font.Style = []
 OldCreateOrder = False
 PixelsPerInch = 96
 TextHeight = 13
 object Button1: TButton
  Left = 64
  Top = 32
  Width = 75
  Height = 25
  Caption = 'Do Something'
  TabOrder = 0
  OnClick = Button1Click
 end
end

This is the error I’m getting in the Chrome debugger:

WebAssembly file VclRoTest.wasm has been loaded.
RemObjectsElements.js:485 [Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.
imp.env.__island_ajaxRequestBinary @ RemObjectsElements.js:485
.Lms_t2c_RemObjects_d_Elements_d_System_d_WebAssembly11_AjaxRequestBinaryns @ wasm-01b24be6-982:85
.Lmi_t3c_RemObjects_d_Elements_d_RTL_d_Delphi_d_VCL_d_TResourceStream3__d_ni64nt24_RemObjects_d_Elements_d_RTL_d_String @ wasm-01b24be6-981:34
.Lmi_t38_RemObjects_d_Elements_d_RTL_d_Delphi_d_VCL_d_TCustomForm3__d_nt37_RemObjects_d_Elements_d_RTL_d_Delphi_d_VCL_d_TComponent @ wasm-01b24be6-1254:168
.Lmi_t32_RemObjects_d_Elements_d_RTL_d_Delphi_d_VCL_d_TForm3__d_nt37_RemObjects_d_Elements_d_RTL_d_Delphi_d_VCL_d_TComponent @ wasm-01b24be6-1257:7
.Lmi_t12_VclRoTest_d_TForm13__d_nt37_RemObjects_d_Elements_d_RTL_d_Delphi_d_VCL_d_TComponent @ wasm-01b24be6-7456:27
mi_t13_VclRoTest_d_Program4_Main @ wasm-01b24be6-7459:57
imp.env.__island_invoke @ RemObjectsElements.js:443
.Lms_t2c_RemObjects_d_Elements_d_System_d_WebAssemblyc_InvokeMethodnp_vna_o @ wasm-01b24be6-6590:302
.Lmi_t2b_RemObjects_d_Elements_d_System_d_MethodInfo6_Invokenona_o @ wasm-01b24be6-5773:1089
.Lmi_tnt2c_RemObjects_d_Elements_d_System_d_WebAssembly18__l__g_c____DisplayClass117__l_GetProxyFor_g_b____2nt31_RemObjects_d_Elements_d_System_d_EcmaScriptObject @ wasm-01b24be6-6938:429
.Lmi_t34_RemObjects_d_Elements_d_System_d_WebAssemblyDelegate6_Invokent31_RemObjects_d_Elements_d_System_d_EcmaScriptObject @ wasm-01b24be6-6924:33
__island_call_delegate @ wasm-01b24be6-6962:18
res @ RemObjectsElements.js:246
(anonymous) @ (index):14
Promise.then (async)
(anonymous) @ (index):11
RemObjectsElements.js:277 Fatal exception in WebAssembly!
RemObjectsElements.js:277 Exception: RemObjects.Elements.System.NullReferenceException: Member access on null reference; for expression: self
wasm-01b24be6-50:27 Uncaught (in promise) RuntimeError: unreachable
    at ElementsRaiseException (wasm-function[50]:74)
    at .Lmi_t39_RemObjects_d_Elements_d_RTL_d_Delphi_d_VCL_d_TApplicationd_get__MainForm (wasm-function[877]:96)
    at .Lmi_t32_RemObjects_d_Elements_d_RTL_d_Delphi_d_VCL_d_TForm3__d_nt37_RemObjects_d_Elements_d_RTL_d_Delphi_d_VCL_d_TComponent (wasm-function[1257]:34)
    at .Lmi_t12_VclRoTest_d_TForm13__d_nt37_RemObjects_d_Elements_d_RTL_d_Delphi_d_VCL_d_TComponent (wasm-function[7456]:62)
    at mi_t13_VclRoTest_d_Program4_Main (wasm-function[7459]:151)
    at imp.env.__island_invoke (https://www.notepage.net/download/dev/wa/wasm/RemObjectsElements.js:443:38)
    at .Lms_t2c_RemObjects_d_Elements_d_System_d_WebAssemblyc_InvokeMethodnp_vna_o (wasm-function[6590]:623)
    at .Lmi_t2b_RemObjects_d_Elements_d_System_d_MethodInfo6_Invokenona_o (wasm-function[5773]:2863)
    at .Lmi_tnt2c_RemObjects_d_Elements_d_System_d_WebAssembly18__l__g_c____DisplayClass117__l_GetProxyFor_g_b____2nt31_RemObjects_d_Elements_d_System_d_EcmaScriptObject (wasm-function[6938]:988)
    at .Lmi_t34_RemObjects_d_Elements_d_System_d_WebAssemblyDelegate6_Invokent31_RemObjects_d_Elements_d_System_d_EcmaScriptObject (wasm-function[6924]:63)

Edit: Forgot to include index.html

<html>
    <head>
        <title>VclRoTest Test Page</title>
        <script lang="javascript" src="wasm/RemObjectsElements.js"></script>
        <script lang="javascript" src="wasm/VclRoTest.js"></script>
    </head>
    <body>
    <h1>VclRoTest Test Page</h1>
    <div id="helloWorld"/>
    <script lang="javascript">
        VclRoTest.instantiate("wasm/VclRoTest.wasm").then(function (result) {
            console.log("WebAssembly file VclRoTest.wasm has been loaded.");
            var program = result.Program();
            program.Main();
        });
    </script>
    </body>
</html>

I’m inviting my colleague @Diego_Navarro to this thread, but I think you have to do the application initialization before you do the form creation.

Hi Chris2, please, try with:

public void Main()
{
TApplication application = new TApplication(null);
application.Initialize();
application.CreateForm(typeOf(TForm1), ref Form1);
application.Run();
}

No need to create a new TForm1, application.CreateForm is taking care, first parameter is the type, TForm1 in this case, second one, the variable when the reference will go.