Data Types C# -> C++, Managed DLL import

Hi guys,

I am currently working on using a Managed .NET dll being imported within my Unreal Project.

Everything is going fine though I am having some difficulties with return types.

So the signature of the function I’m calling from my DLL looks like this:

static byte[] FuncName() {
...
}

I’m properly getting the function within unity though I’m having trouble figuring out the type that UnrealEngine can work with.

Things I’ve tried:

TArray<uint8> array //(crashes on function call, improper return type)
uint8* array //(crashes on accessing the variable. i.e. : sizeof(array) causes crash.

I’ve also attempted to change my signature to:

static unsafe byte* FuncName() {
...
}

though admittedly I am unfamiliar with all of C#'s unsafe rules so I’m probably marshaling the array into byte* incorrectly.

If this made sense to you, or you’ve been in a similar situation and have a solution, please help me out here!

I’ve been smashing my head against this for a few hours and can’t for the life of me figure it out. (at least without some sleep :wink: )

Thanks for any and all help,
-Paul