Internal error: System.InvalidCastException while compiling

When compiling a multi project solution we get this exception from the compiler:

Internal error: System.InvalidCastException: Unable to cast object of type ‘RemObjects.Elements.Code.ExternalTypes.DotNetMethodInfo’ to type ‘RemObjects.Elements.Code.IMutableMethodImplementation’.
at RemObjects.Elements.Code.Compiler.Compiler.CheckIfInterfaceIsImplemented(IParsedType aType, BaseType aInterface, Boolean aIsBase)
at RemObjects.Elements.Code.Compiler.ResolveMembersCompiler.ResolveType__$mapped____(Compiler self, ScopeInfo lScope, IParsedType aType)
at RemObjects.Elements.Code.Compiler.Compiler.ForAllInternalTypes(Action`1 aAt)
at RemObjects.Elements.Code.Compiler.ResolveMembersCompiler.ResolveMembers__$mapped(Compiler self)

Please see log file (full Debug enabled):

Build.zip (20.6 KB)

The error location points to the ‘targets’ file of elements:

What can I do to find the cause of this error?

Thanks!

Unfortunately there;s very little actionable info here top narrow this doen, leta lone reproduce.fix this :slightly_frowning_face:. Is there any chance you could share the project with us (privately, and we will of couere keep it confidential and use it only to reproduce the bug?

Yeah thats normal for erros like that. if MSBuild doesnt have a concrete error line, it blames it on the .targets file ;).

You need these 3 repositories:

git clone https://github.com/a-dato/fmx-datacontrol.git fmx-datacontrol
git clone https://kvermeulen_adato@bitbucket.org/kvermeulen/adato_datamodel.git adato_datamodel_master
git clone https://kvermeulen_adato@bitbucket.org/kvermeulen/adato_wasm.git adato_wasm

The first one is public. For the other two, I sent an invite to talk@remobjects.com.

The project to compile is: adato_wasm\Blazor\BlazorTestApp\BlazorApp2.sln

Thanx. can you send these invites to mh@remobjects.com? Unfortunately with the messages delivered to talk@, i don’t get timely confirmartion codes to accept the invite…

My apologies for the troubles.

Could not find your mail address…

Any way, invitations sent

Hm, that’s a .csproj though?

Thje Elements prokects have many hardcoded paths to D:,, including hadcoded package referneces that are missing.

i get

Package ‘Microsoft.JSInterop:10.0.9’ has no deliverable for platform ‘netcoreapp 8.0’.

After fixing the paxkage reference’s up. which i correct. After i ficed he project to use net10, i get this error, which is also correct:

function AtomicDecrement(var Target: Integer; const Value: Integer := 1): Integer;
begin
	Target := Target - Value;
	Result := Target;
end;

...

function AtomicDecrement(out Target: Int64; const Value: Int64 := 1): Int64; // E58 Duplicate method "class function AtomicDecrement(out Target: Int64; Value: Int64): Int64" with same signature
begin
	Target := Target - Value;
	Result := Target;
end;

After this, i get

    property ReadOnly: Boolean read fReadOnly write fReadOnly; // E509 Unknown identifier "fReadOnly", did you mean "ReadOnly"?
                                                               // E269 Property calls itself recursively
                                                               // E509 Unknown identifier "fReadOnly", did you mean "ReadOnly"?

which is also correct.

Giving up for now.

It looks like I didn’t push all the code. Will double check and back to you.

I have an automatic commit/pull/push script, but the adato_wasm project was not included. All the errors you found are already fixed. Can you pull adato_wasm again and retry?

If you want, we can connect later today or this week to get it going (I’m on CEST).

Missing file:

ignoring that, i ow get

E:                   Unknown identifier "ConvertError", did you mean "EConvertError"? [/Users/mh/temp/kees/adato_wasm/Wasm/Wasm.System.SysUtils.pas (321)]
E:                   Unknown identifier "SFormatTooLong" [/Users/mh/temp/kees/adato_wasm/Wasm/Wasm.System.SysUtils.pas (321)]
E:                   Cannot cast from "<method pointer>" to "EConvertError" [/Users/mh/temp/kees/adato_wasm/Wasm/Wasm.System.SysUtils.pas (321)]
E:                   Unknown identifier "SetString" [/Users/mh/temp/kees/adato_wasm/Wasm/Wasm.System.SysUtils.pas (323)]
E:                   Unknown identifier "FloatToTextFmt" [/Users/mh/temp/kees/adato_wasm/Wasm/Wasm.System.SysUtils.pas (323)]
E:                   Unknown identifier "fvExtended" [/Users/mh/temp/kees/adato_wasm/Wasm/Wasm.System.SysUtils.pas (323)]
E:                   Cannot cast from "String" to "PChar" [/Users/mh/temp/kees/adato_wasm/Wasm/Wasm.System.SysUtils.pas (324)]

it seems i need to deifne DOTNET manually.

with that, ./adato_wasm/Blazor/Delphi/adato_system.elements now compiles. i do get 14 errors, including the/a internal error (doesnt seem to be the same one) and 13 real ones:

E:                   Internal error: System.InvalidCastException: Specified cast is not valid.
  at RemObjects.Elements.Code.Compiler.Compiler.CheckIfInterfaceIsImplemented (RemObjects.Elements.Code.IParsedType aType, RemObjects.Elements.Code.BaseType aInterface, System.Boolean aIsBase) [0x003c6] in <eed51a3d38af4469b1af563ef8695e3c>:0 
  at RemObjects.Elements.Code.Compiler.ResolveMembersCompiler.ResolveType__$mapped____ (RemObjects.Elements.Code.Compiler.Compiler self, RemObjects.Elements.Code.Compiler.ScopeInfo lScope, RemObjects.Elements.Code.IParsedType aType) [0x00cbf] in <55625d610e6b4f5e9f5f041a35ec54c3>:0 
  at RemObjects.Elements.Code.Compiler.ResolveMembersCompiler+<>c__DisplayClass17.<ResolveMembers>b__4 (RemObjects.Elements.Code.IParsedType aType) [0x00000] in <55625d610e6b4f5e9f5f041a35ec54c3>:0 
  at RemObjects.Elements.Code.Compiler.Compiler.ForAllInternalTypes (System.Action`1[T] aAt) [0x00085] in <eed51a3d38af4469b1af563ef8695e3c>:0 
  at RemObjects.Elements.Code.Compiler.ResolveMembersCompiler.ResolveMembers__$mapped (RemObjects.Elements.Code.Compiler.Compiler self) [0x0031f] in <55625d610e6b4f5e9f5f041a35ec54c3>:0 

The IE (a bug, of course) happens in CheckIfInterfaceIsImplemented for

    aType: CombinedParsedType = ADato.FMX.ComboMultiBox.TComboMultiBox
    wt: CombinedParsedType = ADato.FMX.ComboMultiBox.TComboMultiBox

        fInterfaces: BaseType = RemObjects.Elements.Code.BaseType[]
            [0]: CombinedParsedType = FMX.ScrollControl.ControlClasses.Intf.IDCEditControl
            [1]: CombinedParsedType = FMX.ScrollControl.ControlClasses.Intf.IDCControl
            [2]: DotNetType = System_.IBaseInterface

maybe this helps you narrow it down and avoid the error until we fix it. From what i can tell, TComboMultiBox or descendants do implement all three interfaces; the chekc fails for index 0, ie IDCEditControl.

Oddly, notably, this is not the exact same error message as you posted – but thaty could be a Mono vs .NET or a .NET version difference, as the stack seems similar/same

Logged as bugs://E27714.

Thanks, I’ll look at and see if I can fix it in any way.

I have updated the project files to use .NET10.0. Still I only get the same error message as before. I do not get the other errors. There is no need to define DOTNET, it should work without.

I have commited and pushed the adato_wasm repo with these changes.

I tried fixing the compilation error by removing interface IDCEditControl from class TComboMultiBox but the same error occurred, probably in another location. For now I’ll await the fix.