Download MetaTrader 5

C# dll returns numbers instead of string (unmanaged exports)

To add comments, please log in or register
Rosen Marinchev
139
Rosen Marinchev  

I have the following C# function:

 

[DllExport("Call", CallingConvention = CallingConvention.StdCall)]
        [return: MarshalAs(UnmanagedType.LPWStr)]
        public static string Call(
            [MarshalAs(UnmanagedType.LPWStr)]string parameters
            , [MarshalAs(UnmanagedType.LPWStr)]string host)
        {
            try
            {
		string resultValue = "some string";
                return resultValue;
            }
            catch (Exception ex)
            {
                return ex.Message;
            }
        }

The requests are executed correctly, however the response is always a number like this: '91801944'

If I put a message box inside the dll, I can see that the returned string is accurate and displayed correctly. Somehow the string is being converted to numbers while it is passed as return value to mt4 platform. Do you have any idea how I can fix this issue ? 

qjol
3243
qjol  
show the relevant MQL code please
Rosen Marinchev
139
Rosen Marinchev  
#import "SST.dll"
   int Call(string, string);
#import

string strRet = Call("EURUSD;0;0;1", "somehostvalue");
Print(strRet);
Alain Verleyen
Moderator
32455
Alain Verleyen  
moreevilthanyou:

   int Call(string, string);
FXEZ
14
FXEZ  
moreevilthanyou:

The return type from your function "Call" is a string, not an int! See this:

#import "SST.dll"

   string Call(string parameters, string host);

#import

To add comments, please log in or register