Oxygene Build Error (E0) Internal error: System.NullReferenceException: Object reference not set to an instance of an object

This is the Build error I am receiving, could anyone that knows how to fix this let me know?

The compiler version is -
20181217-150705

Line Severity Code Description Project File Suppression State
53 Error (E0) Internal error: System.NullReferenceException: Object reference not set to an instance of an object.
at RemObjects.Oxygene.Code.Output.DotNet.OutputGeneratorVisitor.PushParameters(IParameters pars, BaseType aSelfType, IList1 aGPA) at RemObjects.Oxygene.Code.Output.DotNet.OutputGeneratorVisitor.VisitResolvedCallExpression(ResolvedCallExpression call) at RemObjects.Oxygene.Code.Output.DotNet.OutputGeneratorVisitor.VisitExpression(Expression element) at RemObjects.Oxygene.Code.Output.DotNet.OutputGeneratorVisitor.Push(Expression val) at RemObjects.Oxygene.Code.Output.DotNet.OutputGeneratorVisitor.VisitAssignmentStatement(AssignmentStatement assignmentStatement) at RemObjects.Oxygene.Code.Output.DotNet.OutputGeneratorVisitor.VisitStatement(Statement element) at RemObjects.Oxygene.Code.Output.DotNet.OutputGeneratorVisitor.VisitBeginStatement(BeginStatement beginStatement) at RemObjects.Oxygene.Code.Output.DotNet.OutputGeneratorVisitor.VisitStatement(Statement element) at RemObjects.Oxygene.Code.BaseVisitor.VisitScopeStatement(ScopeStatement element) at RemObjects.Oxygene.Code.Output.DotNet.OutputGeneratorVisitor.VisitScopeStatement(ScopeStatement element) at RemObjects.Oxygene.Code.Output.DotNet.OutputGeneratorVisitor.VisitStatement(Statement element) at RemObjects.Oxygene.Code.Output.DotNet.OutputGeneratorVisitor.VisitStatementExpression(StatementExpression expression) at RemObjects.Oxygene.Code.Output.DotNet.OutputGeneratorVisitor.VisitExpression(Expression element) at RemObjects.Oxygene.Code.Output.DotNet.OutputGeneratorVisitor.Push(Expression val) at RemObjects.Oxygene.Code.Output.DotNet.OutputGeneratorVisitor.VisitBinaryExpression(BinaryExpression binaryExpression) at RemObjects.Oxygene.Code.Output.DotNet.OutputGeneratorVisitor.VisitExpression(Expression element) at RemObjects.Oxygene.Code.Output.DotNet.OutputGeneratorVisitor.Push(Expression val) at RemObjects.Oxygene.Code.Output.DotNet.OutputGeneratorVisitor.VisitBinaryExpression(BinaryExpression binaryExpression) at RemObjects.Oxygene.Code.Output.DotNet.OutputGeneratorVisitor.VisitExpression(Expression element) at RemObjects.Oxygene.Code.Output.DotNet.OutputGeneratorVisitor.Push(Expression val) at RemObjects.Oxygene.Code.Output.DotNet.OutputGeneratorVisitor.VisitIfStatement(IfStatement ifStatement) at RemObjects.Oxygene.Code.Output.DotNet.OutputGeneratorVisitor.VisitStatement(Statement element) at RemObjects.Oxygene.Code.Output.DotNet.OutputGeneratorVisitor.VisitBeginStatement(BeginStatement beginStatement) at RemObjects.Oxygene.Code.Output.DotNet.OutputGeneratorVisitor.VisitStatement(Statement element) at RemObjects.Oxygene.Code.BaseVisitor.VisitScopeStatement(ScopeStatement element) at RemObjects.Oxygene.Code.Output.DotNet.OutputGeneratorVisitor.VisitScopeStatement(ScopeStatement element) at RemObjects.Oxygene.Code.Output.DotNet.OutputGeneratorVisitor.VisitStatement(Statement element) at RemObjects.Oxygene.Code.Output.DotNet.Output.GenerateMethod(IMutableMethodImplementation meth) at RemObjects.Oxygene.Code.CombinedParsedType.ForAllMethods(Func2 action)
at RemObjects.Oxygene.Code.Output.DotNet.Output.GenerateMethods(IMutableParsedType aType)
at RemObjects.Oxygene.Code.Output.DotNet.Output.GenerateMethods()
at RemObjects.Oxygene.Code.Output.DotNet.Output.CreateDotNetGenerator(Stream s)
at RemObjects.Oxygene.Code.Output.DotNet.Output.GenerateExecutable()
at RemObjects.Oxygene.Code.Compiler.Compiler.GenerateExecutable()
at RemObjects.Oxygene.Code.Compiler.Compiler.Compile() RPMVC C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\RemObjects Software\Elements\RemObjects.Elements.Echoes.targets

Timothy,

my apologies for that. this is by definition a compiler bug, and should not happen. We will most likely need a test case in order to reproduce it, though — can you send us the project that shows this?

Marc,

Thank you for replying so quickly.

The project is attached.

RPMVC.zip

I know there is some problem with the code, but since there are some thousands of lines of code it would be nice if the compiler would show the line or area of the code that is at fault.

The files that cause the bug are either - RpStrFuncs.pas, RpNumFuncs.pas or RpFormatFuncs.pas.

After I sent the email earlier I went and removed all the files from the models folder and then added them one at a time and then compiled until I got to these files and the error re-occurred.

Some of this code is very old, originally written in legacy Turbo Pascal v3 in the 80’s.

What I have is a Delphi XE10.3 system that compiled 1.5 million lines of code, quiet a large project, so I am looking at the feasibility of moving 3 or 4 hundred thousand lines of code to an ASP.NET environment, writing a new front end for it in HTML. So the code in these 3 files is functions for format and convert strings, numeric fields and dates, some of which will not be required if I proceed with this project.

These 3 files contain circular unit references to some degree, which I though might be an issue, for example each of these 3 units require each other to compile, so I combined all 3 into a single file, but alas the same problem occurs when I build the project.

Of concern if I proceed is the ability to compile this code in Oxygene once the code size gets large as a failure to compile would mean the end of this project and hence my retirement income.

Of course, yes. This is b y definition a bug, and needs to be fixed. The compiler should always give an exact location.

Reproduced the error, logging.

Thanks, logged as bugs://81649

Marc,

I found the source of the build error, see the code below, the line -
dollars_and_centsX := Round( dollars_and_centsX * 100 ) / 100;

I guess that the Round function object needs to be created first before calling it?
This code was copied from some very old Delphi code, 20 years plus.

procedure round_cents ( var dollars_and_centsX :double );
var
DCStr : DelphiString;
begin
//if (frac(dollars_and_cents * 100) = 0.5) then
if (Frac(dollars_and_centsX * 100 ) >= 0.499) and
(Frac(dollars_and_centsX * 100 ) <= 0.6) then
begin
dollars_and_centsX := dollars_and_centsX + 0.001;
end;

DCStr := str_r(dollars_and_centsX, 0);
dollars_and_centsX := make_real(DCStr);
dollars_and_centsX := Round( dollars_and_centsX * 100 ) / 100;
end;

I think I found it. The error will improve of course, but you should reference elements.dll too, that should fix it.

bugs://81649 got closed with status fixed.

So Carlo, what is the fix for this ? How do I reference elements.dll ?

Hrmm show it doesn’t show in references in the last builds.

Add a reference to:
C:\Program Files (x86)\RemObjects Software\Elements\Echoes\Reference Assemblies\NET\Elements.dll

directly should fix it (the next build will properly fail on this)

A post was split to a new topic: NRE in compiler compiling project