Hi Arcady,
You need some kind of facade or adapter in front of your .NET class when your .NET object structure is outside the supported structures of PB's native .NET interop. The exact same issues occur when you use COM Callable Wrapper as .NET Interop technology.
About 10 years ago I worked on app that called national databases exposing their interfaces via web-services. We could not connect directly from PB 11.5, nor PB 12.5 later on. We had to write facade in C#. We used COM callable wrapper to call C# written assembly from PowerScript.
Data structures passed back and forth were very complex highly nested data structures. Arrays of structs of arrays of structs of . . . You get the picture I assume.
Now, such structure is impossible to pass directly via COM. Same if using PB native .NET interop. Here is what we did:
* Each public API of our C# facade followed this pattern:
function CreateSuperFundSite( string IN-data )
return string // OUT-data
throws exceptions
The IN-data was an XML-string encapsulating the complete input data structure. Often 5+ nested layers of arrays of structs.
The OUT-data return value was also an XML-string encapsulating similar complete data structure.
These days I would use JSON instead of XML but same design pattern: Facade to hide complexity. Typically one PB facade class taking whatever PB data structures marshall to interchange format; call .NET facade; accept return data and unmarshall from interchange format.
On the .NET side the front-end C# class simply unmarshalled the IN-data; initiated whatever processing required; marshalled result and returned it.
It works! /Michael