Unexpected class found in stream

**Using Beta RemObjects Remoting SDK for Delphi - 9.3.0.1323**

I am getting the error something like:

An exception was raised on the server: Error reading parameter AData: Unexpected class found in stream; class "TMyROComplexType" does not descend from "TMyROComplexType".

It is streng that the same type is twice in the message. And my RODL for this types looks like:

TMyROComplexType = class(TROComplexType)
...
end;

...

TMyANOTHERROComplexType = class(TROArray<TMyROComplexType>);

I have generated the _intf and _serveraccess files using the latest rodl2code.exe

By generating there is a bug also: not all units are added, e.g. I had to add manually these units in each _ServerAccess file:

System.TypInfo, uROClientIntf, uROAsync, uROServerLocator, uROBinMessage

Do you have any ideas?

Thx!

This error comes in this code:

line : if not lActualClass.InheritsFrom(aClass) then RaiseError(err_UnexpectedClassInStream,[clsnme,aClass.ClassName]);

function TROStreamSerializer.ReadStruct(const aName: string;
  aClass: TClass; var Ref; ArrayElementId: integer): Boolean;
var
  obj : TROComplexType absolute Ref;
  IsAssigned : ByteBool;
  clsnme : string;
  lActualClass:TROComplexTypeClass;
begin
  fStream.ReadBuffer(IsAssigned, SizeOf(IsAssigned));
  Result := IsAssigned;
  if Result then begin
    ReadLegacyString('', clsnme,[paAsUTF8String],-1,MAX_ITEM_NAME);
    lActualClass := FindROClass(clsnme,DefaultNamespaces);
    if not Assigned(lActualClass) then RaiseError(err_UnknownClassInStream,[clsnme,aClass.ClassName]);
    if not lActualClass.InheritsFrom(aClass) then RaiseError(err_UnexpectedClassInStream,[clsnme,aClass.ClassName]);
    obj := lActualClass.Create;
    try
      obj.ReadComplex(self);
    except
      FreeAndNil(obj);
      raise;
    end;
  end
  else
    Obj:=nil;
end;

this exception can be raised if you are using Hydra.
in this case plugin and host use own copies of this class and it leads to this error.

weird, _ServerAccess is generated by default (for http://yourserver.example.com:8099/bin ) with

  {$IFDEF DELPHIXE2UP}System.SysUtils{$ELSE}SysUtils{$ENDIF},
  {$IFDEF DELPHIXE2UP}System.Classes{$ELSE}Classes{$ENDIF},
  uROComponent,
  uROMessage,
  uROBaseConnection,
  uROTransportChannel,
  uROBinMessage,
  uROBaseHTTPClient,
  uROIndyHTTPChannel,
  NewLibrary_Intf;

and it is enough for compiling this unit.
why you add uROBinMessage manually - I don’t know …

I have added manually because the rodl2code.exe has this output:

uses
  {$IFDEF DELPHIXE2UP}System.SysUtils{$ELSE}SysUtils{$ENDIF},
  {$IFDEF DELPHIXE2UP}System.Classes{$ELSE}Classes{$ENDIF},
  uROComponent,
  uROMessage,
  uROBaseConnection,
  uROTransportChannel,
  uROBaseHTTPClient,
  uROIndyHTTPChannel,
  MyServicesLibrary_Intf;

do you generate files from RODL or from URL ?
if you generate it from URL, includes it protocol like http://localhost:8099/Bin or not?
can you show your parameters for rodl2code.exe, pls?

Oh… :frowning: It was my fault… sorry… After your questions I could solve the proble… I am very sorry!

I am generating the files from the URL and the problem was that I had as parameter http://localhost:8099/rodl and not /bin

The problem is sloved! Thank you! :slight_smile:

I have tested again this issue and I am still getting this error. I don’t use Hydra. I am accessing the server through the RORemoteService, Indy and ROBinMessage…

If I am using the JSON message everthing is okay :frowning:

can you create a simple testcase that reproduces this problem, pls?
you can send it directly to support@ or attach here

Yeeeees! I found the problem! It was me :man_facepalming:

I have multiple services and they are accessing each other through the _intf and _serveraccess… and in one service I had a self-reference to the own _intf and _serveraccess files…

Thank you for your help! :slight_smile: