the DLL made with c # does not work at mt4.

To add comments, please log in or register
Mehmet Bastem
1673
Mehmet Bastem  

The DLL made with c # does not work at mt4.

the following error occurs. I would appreciate if you help.

2018.11.27 17:15:12.066 Libdeneme1 EURUSD,M5: unresolved import function call

2018.11.27 17:15:12.066 Cannot find 'Add' in 'testme.dll'

(https://www.mql5.com/en/articles/249)

c# code and mql4 code included.

#property copyright "Copyright 2010, Investeo.pl"
#property link      "http:/Investeo.pl"
#property version   "1.00"

#import "Testme.dll"
   int Add(int left,int right);
   int Sub(int left,int right);
   float AddFloat(float left,float right);
   double AddDouble(double left,double right);
#import

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   for(int i=0; i<3; i++)
     {
      Print(Add(i,666));
      Print(Sub(666,i));
      Print(AddDouble(666.5,i));
      Print(AddFloat(666.5,-i));
     }
  }
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RGiesecke.DllExport;
using System.Runtime.InteropServices;


namespace Testme
{
    public class testme
    {
         [DllExport("Add", CallingConvention = CallingConvention.StdCall)]
       
        public static int Add([MarshalAs(UnmanagedType.LPWStr)] int left, [MarshalAs(UnmanagedType.LPWStr)] int right)
        {
            return left + right;
        }

        [DllExport("Sub", CallingConvention = CallingConvention.StdCall)]
        public static int Sub(int left, int right)
        {
            return left - right;
        }

        [DllExport("AddDouble", CallingConvention = CallingConvention.StdCall)]
        public static double AddDouble(double left, double right)
        {
            return left + right;
        }

        [DllExport("AddFloat", CallingConvention = CallingConvention.StdCall)]
        public static float AddFloat(float left, float right)
        {
            return left + right;
        }
    }
}


Exposing C# code to MQL5 using unmanaged exports
Exposing C# code to MQL5 using unmanaged exports
  • www.mql5.com
I was looking for a long time to find a simple solution that would enable me to use managed mode C# DLLs in MQL5. After reading many articles I was ready to implement C++ wrapper for managed DLL when I came across a brilliant solution that saved me many hours of work. The solution provided a simple example of exporting managed C# code to be...
Mehmet Bastem
1673
Mehmet Bastem  

Problem is solved.

https://www.mql5.com/en/forum/293517#comment_9811172

MT4 DLL Not Support
MT4 DLL Not Support
  • 2018.12.04
  • www.mql5.com
MT4 also developed by its own company does not work why the DLL. Script under DLLSampleTester.mq4...
To add comments, please log in or register