Anthony Harrison · May 27

How to convert a %Stream.GlobalBinary into a byte array to pass to a DLL

We need to know how to pass a certain value, which in the .NET world is described as a byte array (i.e. byte[])


We have various libraries that were created in .NET 4.5 that are registered for COM interom, an example that we have is as follows:

.NET Signature:

public static byte[] CreateQrCode(string content, int width, int height, string imageFormat)

.NET utilisation:

byte[] image = Writer.CreateQrCode("http://redacted/", 100, 100, "png");

Intersystems utilisation:

do streamQrCode.CopyFrom(objGenerator.CreateQrCode("http://redacted/",100,100,"png"))


PROBLEM: We need to know what object to pass from Intersystems that the .NET DLL will receive it as a byte[] (i.e. byte array). The two values that we don't know how to pass are howtopassthis1 and howtopassthis2

.NET Signature:

byte[] DrawImage(byte[] backgroundImage, byte[] imageToDraw, float x, float y, float width, float height, string imageFormat)

.NET Utilisation:

byte[] resultingimage = Writer.DrawImage(backgroundimage, smallimage, 1400, 600, 600, 300, "png");

Intersystems Utilisation:

do streamNewImage.CopyFrom(objGenerator.DrawImage(howtopassthis1, howtopassthis2, 1400, 600, 600, 300, "png"))


Can anyone help us pass howtopassthis1 and howtopassthis2?

1 0 4 70
Log in or sign up to continue

Did you see these examples? I'm not an expert in .Net, but as I understood the documentation correctly, you must pass stream as is to .Net method with byte[] as is, and the Gateway should map it, for you.

Thanks, Dmitry, you're a hero!

I'm actually the .NET developer on the project, I passed your answer to the Cache developer and he's over the moon with delight!

I can't you provide a .Net help but there are methods in IRIS/Cache to create QR code:

##class(%SYS.QRCode).GenerateFile(...) and

so your developers could have a direct use instead of messing with passing data back and fort between IRIS/Cache and .Net

Thanks Julius, but our DLL does all of the following, as well as compiling on our build server to work in our mobile app, in Docker Containers, and in Microsoft Azure -  it's more effective to retain complex business rules in a .NET library so that it can be used on a much wider basis. Also, .NET is easier to maintain in the sense that adding any new barcode format to the DLL updates all of our environments, not just the Cache one. We're into microservices in a big way, Cache is just our facade pattern entrypoint to the whole distributed system. Alot of the business rules tranlation is done simply by exchanging JSON at the microservice REST endpoints (we've also got a QR code Server in a docker container that's standalone and accessible by anything via a REST endpoint), however somtimes it's easier just to slap in a DLL as per the above question. Also, a lot of our team's expertise is tied up in .NET technologies so quite often a .NET solution is quicker and easier than passing the technology transfer information to the Cache developers. Thanks though.

Aztec 2D barcode format.

CODABAR 1D format.

Code 128 1D format.

Code 39 1D format.

Code 93 1D format.

Data Matrix 2D barcode format.

EAN-13 1D format.

EAN-8 1D format.

ITF (Interleaved Two of Five) 1D format.

MaxiCode 2D barcode format.

PDF417 format.

QR Code 2D barcode format.

RSS 14


UPC-A 1D format.

UPC-E 1D format.

UPC/EAN extension format.