End Google Ads 201810 - BS.net 01 --> Hi,
I've created a c-shared matlab library, which I want to use in my solution.
Using DllImport I can initialize the matlab environment, initialize my matlab model
and send parameters to this dll.
All works wel..., except I can't get the results!

In matlab, I've got a simple (test) function which returns a fixed value: 1234.
The created library has the following .h file:
extern LIB_Matlab_Test_C_API bool MW_CALL_CONV mlfMatlab_test(int nargout
, mxArray** steps
, mxArray* test_string
, mxArray* nog_een_test_string);

This is how I interface to the dll:
///
/// One and only function in the matlab model
///
/// string
/// True if successfull, false otherwise
[DllImport("Matlab_Test.dll", EntryPoint = "mlfMatlab_test")]
static extern bool Matlab_Test(
[Out][MarshalAs(UnmanagedType.I4)]int nargout,
IntPtr return_value,
[In][MarshalAs(UnmanagedType.LPStr)]string myString,
[In][MarshalAs(UnmanagedType.LPStr)]string mySecondString);

And finally, calling the function:
int nargout = 1;
IntPtr pbuf = Marshal.AllocHGlobal(256);
Matlab_Test(nargout, pbuf,"dummy string", "yet another dummy string");
int sOut = Marshal.ReadInt32(pbuf);
Console.WriteLine("\t\tsucceeded! Value = {0}", sOut);
Marshal.FreeHGlobal(pbuf);

The value of sOut always remains zero

Does anyone have an idea of what I'm doing wrong here?

-- Stupidity should be painfull --