How do I create a DLL with functions that can be imported into MetaTrader 5 using C# in Visual Studio 2022?
I tried using this code:
using System;
using System.Runtime.InteropServices;
using RGiesecke.DllExport;
public class MyClass
{
[DllExport("AddNumbers", CallingConvention = CallingConvention.StdCall)]
public static int AddNumbers(int a, int b)
{
return a + b;
}
}
and after i create .mql5 and put the dll in the same folder , in library and in include this my code :
#import "MyMQL5DLL.dll"
int AddNumbers(int a, int b);
#import
void OnStart()
{
int result = AddNumbers(5, 3);
Print("The result is: ", result);
}
but unfortunately not work always return me this error:
2025.03.23 15:13:10.720 TEST (XRPUSD,M1) cannot find 'int MyMQL5DLL::AddNumbers(int,int)' in module 'MyMQL5DLL.dll' 2025.03.23 15:13:10.721 TEST (XRPUSD,M1) unresolved import function call in 'TEST.mq5' (1,1)
Anyone have some idea ?
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744277289a4566393.html
评论列表(0条)