#1 2021-06-24 17:28:07

tbo
Member
Registered: 2015-04-20
Posts: 339

Exception: Rtti.Count=2 at mormot.core.json start

Delphi 2007, mORMot2 GitHub commit 1488

I have completely changed my program from mORMot1 to mORMot2. Not completely, there is still one place missing. Until then everything works fine. If I change the last piece to mORMot2, the following error message comes up when I start the program:

exception class: EJSONException
exception message: Rtti.Count=2 at mormot.core.json start.

It is triggered in unit mormot.core.json in the function:

procedure InitializeUnit; 
...
  if Rtti.Count > 0 then
    raise EJSONException.CreateUtf8(
      'Rtti.Count=% at mormot.core.json start', [Rtti.Count]);

Before that I make the following change in source code:

//  , SynCommons  // Umstellung mORMot1 -> mORMot2
  , mormot.core.base
  , mormot.core.data

And during initialization:

//  FIndexHashed.InitSpecific(TypeInfo(TIndexItemArray), FIndex, djString, @FIndexCount);  // Umstellung mORMot1 -> mORMot2
  FIndexHashed.InitSpecific(TypeInfo(TIndexItemArray), FIndex, ptString, @FIndexCount);

The definition is as follows:

  strict private
    type
      TIndexItem = record
        groupName: String;
        mapObjList: TVisMappingObjArray;
      end;

      TIndexItemArray = array of TIndexItem;
  strict private
    FIndex: TIndexItemArray;
    FIndexCount: Integer;
    FIndexHashed: TDynArrayHashed;

Can anyone give me a hint what I am doing wrong? If I change the two source code places back to mORMot1, my program runs again. Thanks a lot for the help.

With best regards...
Thomas

Last edited by tbo (2021-06-24 17:35:04)

Offline

#2 2021-06-25 12:44:02

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,350
Website

Re: Exception: Rtti.Count=2 at mormot.core.json start

Always put mormot.core.json in the uses clause in the unit where you register the type via FIndexHashed.InitSpecific().

I will make the error message more explicit.

Offline

#3 2021-06-25 15:04:09

tbo
Member
Registered: 2015-04-20
Posts: 339

Re: Exception: Rtti.Count=2 at mormot.core.json start

ab wrote:

I will make the error message more explicit.

Now it works. Thanks for the help. The new exception message is very helpful. Maybe one space too many "[ %]". Have a nice weekend.

With best regards...
Thomas

Offline

#4 2021-06-25 18:55:59

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,350
Website

Re: Exception: Rtti.Count=2 at mormot.core.json start

There will be some types, so the space is fine: [ Type1 Type2 Type3 ].

Offline

Board footer

Powered by FluxBB