cannot call 'void file::Function()', module 'file.dll' is not loaded

 

Hi . I created a DLL file and placed it in my Expert folder and called the function inside it in my Expert. It works fine on my system but it doesn't work on other systems or on my server and it gives a loading error. I am sure of the path of the DLL file and Expert but I don't know why it doesn't work. Can you help me solve this problem?

File on other systems:

cannot load 'C:\Users\Administrator\AppData\Roaming\MetaQuotes\Terminal\38D9B44642AC6E1AE271759497B11EB5\MQL5\Experts\ClientsURL2.dll' [126]
cannot call 'void ClientsURL2::GetProjectData(int,char&[],int)', module 'ClientsURL2.dll' is not loaded
unresolved import function call in 'NON STOP Automated__V1.7__4.mq5' (1,1)

Code inside Expert:

#include <JAson.mqh>
int numCount = (int)AccountInfoInteger(ACCOUNT_LOGIN);
string testURL = "https://Example.run/api/v1/getClients/" + string(numCount);
bool permission = false;
void connection()
  {
   CJAVal myJason;
   string headers = "Content-Type: application/json", resHeader = "", req = ""; // Set Content-Type header to specify JSON data
   uchar post[], resultBytes[];
   ArrayResize(post, StringToCharArray(req, post, 0, WHOLE_ARRAY, CP_UTF8) - 1);
   int res = WebRequest("GET", testURL, headers, 1000, post, resultBytes, resHeader);
   string data = CharArrayToString(resultBytes); // Convert char array to string
   if(myJason.Deserialize(data, CP_UTF8) && data != "")
     {
      Print("ID = ", myJason["id"].ToInt());
      Print("Name = ", myJason["name"].ToStr());
      Print("AccountNumber = ", myJason["AccountNumber"].ToInt());
      Print("Permission = ", myJason["activeProject"].ToBool());
      permission = myJason["activeProject"].ToBool();

      if(!permission)
        {
         string message = ("You're not allowed to use this file.\nContact your programmer...");
         MessageBox(message, "Permission Denied", MB_OK | MB_ICONWARNING);
         Print(message);
         ExpertRemove(); // Remove the expert if permission is denied
        }
     }
   else
     {
      string message = ("Error parsing server response.");
      MessageBox(message, "Data Error", MB_OK | MB_ICONERROR);
      Print(message);
      ExpertRemove();
     }
  }
 
Step-1: You need to run your MetaTrader in the portable mode. To use this mode, start the platform from the command line with the additional /portable key. For example, "C:\Program Files\MyTerminal\terminal.exe /portable"

https://www.metatrader5.com/ en/terminal/help/start_ advanced/start 

Platform Start - For Advanced Users - Getting Started - MetaTrader 5 Help
Platform Start - For Advanced Users - Getting Started - MetaTrader 5 Help
  • www.metatrader5.com
After installation, a group of programs of the trading platform is added to the Start menu, and the program shortcut is created on the desktop. Use...
 
Oleksandr Medviediev #:
Step-1: You need to run your MetaTrader in the portable mode. To use this mode, start the platform from the command line with the additional /portable key. For example, "C:\Program Files\MyTerminal\terminal.exe /portable"

https://www.metatrader5.com/ en/terminal/help/start_ advanced/start 

Why is that ?

DLL import is working using portable mode or not.

 
mammad0990:

Hi . I created a DLL file and placed it in my Expert folder and called the function inside it in my Expert. It works fine on my system but it doesn't work on other systems or on my server and it gives a loading error. I am sure of the path of the DLL file and Expert but I don't know why it doesn't work. Can you help me solve this problem?

File on other systems:

cannot load 'C:\Users\Administrator\AppData\Roaming\MetaQuotes\Terminal\38D9B44642AC6E1AE271759497B11EB5\MQL5\Experts\ClientsURL2.dll' [126]
cannot call 'void ClientsURL2::GetProjectData(int,char&[],int)', module 'ClientsURL2.dll' is not loaded
unresolved import function call in 'NON STOP Automated__V1.7__4.mq5' (1,1)

Code inside Expert:

Do you URL have dependencies ? Usually error 126 is related to missing dependencies. It could also be incompatible system (32 bits/64 bits...).
 
Alain Verleyen #:
Do you URL have dependencies ? Usually error 126 is related to missing dependencies. It could also be incompatible system (32 bits/64 bits...).
Actually I don't know if it has dependencies or not. I bought the URL from a site and tested it many times on different systems and it worked fine. Now I don't want the customer to know which URL I'm using so I created a DLL file. This file works on my system and it works fine but on other systems it gives this error.
Can you tell me more about URL dependencies or error 126? Do you have a solution for them?
 
mammad0990 #:
Actually I don't know if it has dependencies or not. I bought the URL from a site and tested it many times on different systems and it worked fine. Now I don't want the customer to know which URL I'm using so I created a DLL file. This file works on my system and it works fine but on other systems it gives this error.
Can you tell me more about URL dependencies or error 126? Do you have a solution for them?

Look here : https://stackoverflow.com/questions/14361992/how-do-i-fix-dll-load-library-error-code-126

You can check the dependencies, they verify or ask your customer to verify his system.

How do I fix DLL Load Library - Error Code 126?
How do I fix DLL Load Library - Error Code 126?
  • 2013.01.16
  • Spamdark Spamdark 1,391 2 2 gold badges 20 20 silver badges 38 38 bronze badges
  • stackoverflow.com
I'm using the from the Windows API, when I run the application, it throws me an error code 126. I read that it may be caused by dependencies, I checked what's wrong with some applications like Dependency Walker, but everything was fine. LoadLibrary in the application:
 

mammad0990:

cannot load 'C:\Users\Administrator\AppData\Roaming\MetaQuotes\Terminal\38D9B44642AC6E1AE271759497B11EB5\MQL5\Experts\ClientsURL2.dll' [126]

This is a mess, guaranteed nerves in the future, therefore Step-1.

Step-2: make DLL working.

Thanks.