Open RomanGirin opened 4 months ago
Also add a small remark as a comment: this example IMHO is very important because returning values via pre-created buffer is very often used idiom. Actually this is the only way(?) to return a string from managed side to native. So without this kindly requested addition the sample is incomplete. Thank you in advance!
[CustomHostClr Sample doesn't work with returning values]
I worked through this sample core/hosting/src. There is a missing sample for invocation when some value retuned from the managed side via pre-defined buffer. I tried to add this sample myself but it doesn't seem to work.
On the native side (in nativehost.cpp line ~190) added:
In the Lib.cs I added:
It outputs:
Please, add this kind of example I sketch above (with some fixes required) into the sample.
UPDATE: To fix reported behaviour
On the native side (in nativehost.cpp line ~190) added:
Note the change of type for out_res pointer from wchat_t to char. And then it works (the output is below):
It's strange that marshaled back string is 8-bit instead of 16-bit. If you let me know I'll create issue in more relevant repo about this possible CLR marshaling bug.
Issue metadata