Unresoved import call (x64)

To add comments, please log in or register
Michael
708
Michael  

Now, the code I'm going to post works flawlessly in MT4 and the platform is set to x86 in visual studio.  But in MT5 (x64) and x64 set as the platform in Visual Studio, I get "Can not find <function name> inside <dll name>.dll".

EA code:

//+------------------------------------------------------------------+
//|                                                      DLLTest.mq5 |
//|                        Copyright 2016, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#import "DLLTest.dll"
bool PutGoForNums(double n1, double n2);
double GoForNums(double& n1, double& n2);
#import
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   TestMe();
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
  
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
  
  }
//+------------------------------------------------------------------+

void TestMe()
{
   bool DidItWork=false;
   double Total=0.0, nr1=0.0, nr2=0.0;
   DidItWork=PutGoForNums(3.0, 5.0);
   Total=GoForNums(nr1,nr2);
   Print("nr1:",nr1);
   Print("nr2:",nr2);
   Print("Total:",Total);
}

DLL Code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using RGiesecke.DllExport;

namespace DLLTest
{
    public class DataEx
    {
        struct MyStruct
        {
            
            public double num1;
            public double num2;
        }

        static MyStruct DataSet;

        [DllExport]
        public static double GoForNums(out double n1, out double n2)
        {
            n1 = DataSet.num1;
            n2 = DataSet.num2;
            return (DataSet.num1 * DataSet.num2);
        }

        [DllExport]
        public static double GetData()
        {
            return (DataSet.num1);
        }

        [DllExport]
        public static bool PutGoForNums(double n1, double n2)
        {
            DLLTest.DataEx.DataSet.num1 = n1;
            DLLTest.DataEx.DataSet.num2 = n2;
            return (true);
        }
    }
}
Michael
708
Michael  
Michael:

Now, the code I'm going to post works flawlessly in MT4 and the platform is set to x86 in visual studio.  But in MT5 (x64) and x64 set as the platform in Visual Studio, I get "Can not find <function name> inside <dll name>.dll".

EA code:

//+------------------------------------------------------------------+
//|                                                      DLLTest.mq5 |
//|                        Copyright 2016, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#import "DLLTest.dll"
bool PutGoForNums(double n1, double n2);
double GoForNums(double& n1, double& n2);
#import
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   TestMe();
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
  
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
  
  }
//+------------------------------------------------------------------+

void TestMe()
{
   bool DidItWork=false;
   double Total=0.0, nr1=0.0, nr2=0.0;
   DidItWork=PutGoForNums(3.0, 5.0);
   Total=GoForNums(nr1,nr2);
   Print("nr1:",nr1);
   Print("nr2:",nr2);
   Print("Total:",Total);
}

DLL Code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using RGiesecke.DllExport;

namespace DLLTest
{
    public class DataEx
    {
        struct MyStruct
        {
            
            public double num1;
            public double num2;
        }

        static MyStruct DataSet;

        [DllExport]
        public static double GoForNums(out double n1, out double n2)
        {
            n1 = DataSet.num1;
            n2 = DataSet.num2;
            return (DataSet.num1 * DataSet.num2);
        }

        [DllExport]
        public static double GetData()
        {
            return (DataSet.num1);
        }

        [DllExport]
        public static bool PutGoForNums(double n1, double n2)
        {
            DLLTest.DataEx.DataSet.num1 = n1;
            DLLTest.DataEx.DataSet.num2 = n2;
            return (true);
        }
    }
}

Never mind.  Fixed it.

Re-did DLL from scratch.  In the process this time, I set the platform to x64 BEFORE I installed the nugget packages for Robert's DLLExport package. 

I should've remembered that.

To add comments, please log in or register