How to Import C# DLL into MQL5 script
How to Import C# DLL into MQL5 script
Loading saved threads...
Yashar Safarzadeh · External communityPost link
External question — Stack Overflow Stack Exchange
Author: Yashar Safarzadeh
Original post: https://stackoverflow.com/questions/63071560
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
I want to import following C# code which works fine as a dll into MQL5. would you please help me how to do the binding? (I am using Visual Studio 2015).
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace Keygen
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form2());
}
}
}
The MQL5 code is:
#property strict
#import "Keygen.dll"
void Program();
#import
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
//---
Program();
}
//+--
----------------------------------------------------------------+
after compiling in mql5 I get following the error:
Cannot find 'Program' in 'Keygen.dll'
unresolved import function call
Quote
Report
Yashar Safarzadeh · External communityPost link
External answer — Stack Overflow Stack Exchange
Author: Yashar Safarzadeh
Original post: https://stackoverflow.com/a/63152531
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
I solved this problem by putting the 64bit dll file in "Libraries" folder of MT5 Terminal and changing the MQL code like this.
#import "Keygen.dll"
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
Program::Main();
}
//+------------------------------------------------------------------+
Quote
Report
Ondrej Hlouzek · External communityPost link
External answer — Stack Overflow Stack Exchange
Author: Ondrej Hlouzek
Original post: https://stackoverflow.com/a/69183900
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
I had the same problem. And finally I figured it out. Assembly name, default namespace in project property and namespace name must be the same! Then everything will work as it should.
Quote
Report
Post Reply
Quoted from Forex.com.bd-Editorial External answer — Stack Overflow Stack Exchange Author: Yashar Safarzadeh Source score (net votes, not local likes): 1 Original post: https://stackoverflow.com/a/63152531 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I solved this problem by putting the 64bit dll file in "Libraries" folder of MT5 Terminal and changing the MQL code like this. #import "Keygen.dll" //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { Program::Main(); } //+------------------------------------------------------------------+
Checking account access…