Discussion of article "MetaTrader 5 on Linux" - page 24

 
Hi everyone!
I'm running Metatrader 5 build 3815 on wine-8.0.1 in 64-bit Ubuntu 20.04.6 LTS.
In my Expert Advisor I use a function from imported C# DLL (.NET Framework 4.8). Regardless of what the exported function do, the Expert works well the first time I launch it, and the second time Metatrader 5 just crashes. Debugger never hit breakpoints in the Expert before Metatrader 5 crashes.
Looks like some resources related to the DLL are not being released after the Expert deinitialization. 
Is there a way to fix this?

C# DLL code:
namespace Test
{
    public static class TestStatic
    {
        public static string TestFunc()
        {
            return "test return value";
        }
    }
}
Expert Advisor code:
#import "Test.dll"
#import

int OnInit()
  {
   // 2nd run crash if this line used
   Print("DLL function result: ", TestStatic::TestFunc());
   
   // no 2nd run crash if this line used
   //Print("no DLL functions used");
   
   return(INIT_SUCCEEDED);
  }
void OnDeinit(const int reason){}
void OnTick() {}

 
WStranger #:
Hi everyone!
I'm running Metatrader 5 build 3815 on wine-8.0.1 in 64-bit Ubuntu 20.04.6 LTS.
In my Expert Advisor I use a function from imported C# DLL (.NET Framework 4.8). Regardless of what the exported function do, the Expert works well the first time I launch it, and the second time Metatrader 5 just crashes. Debugger never hit breakpoints in the Expert before Metatrader 5 crashes.
Looks like some resources related to the DLL are not being released after the Expert deinitialization. 
Is there a way to fix this?

C# DLL code:
Expert Advisor code:

I guess a wine reboot windows will do it...


 
Dominik Christian Egert #:
I guess a wine reboot windows will do it...


Tried, didn't help. Every second EA launch since the terminal start results in a crush, even after wineboot
 
WStranger #:
Tried, didn't help. Every second EA launch since the terminal start results in a crush, even after wineboot
I am not sure, but I think I had the same issue on windows as well....

But I cannot remember how I solved it. Or if I solved it for that matter....

How do you terminate the EA?
 
WStranger #:
Hi everyone!
I'm running Metatrader 5 build 3815 on wine-8.0.1 in 64-bit Ubuntu 20.04.6 LTS.
In my Expert Advisor I use a function from imported C# DLL (.NET Framework 4.8). Regardless of what the exported function do, the Expert works well the first time I launch it, and the second time Metatrader 5 just crashes. Debugger never hit breakpoints in the Expert before Metatrader 5 crashes.
Looks like some resources related to the DLL are not being released after the Expert deinitialization. 
Is there a way to fix this?

C# DLL code:
Expert Advisor code:

Yes, I know what's the issue.

Your DLL is not handling load and unload messages properly.

You are missing the minimum required code for proper loading and unloading of DLLs.


 

Dominik Christian Egert #:

How do you terminate the EA?

I delete it manually from a chart or stop it with debugger - result is the same in both cases.

Dominik Christian Egert #:

You are missing the minimum required code for proper loading and unloading of DLLs.
Do you have any specs or code sample explaining how to do this properly? Because MQL5 spec says otherwise. Also my experince says otherwise: I'm using .NET libraries in multiple MQL5 projects and it works as expected in Windows 8.1/10/11.
 
WStranger #:

I delete it manually from a chart or stop it with debugger - result is the same in both cases.

Do you have any specs or code sample explaining how to do this properly? Because MQL5 spec says otherwise. Also my experince says otherwise: I'm using .NET libraries in multiple MQL5 projects and it works as expected in Windows 8.1/10/11.

EDIT:

 
WStranger #:

I delete it manually from a chart or stop it with debugger - result is the same in both cases.

Do you have any specs or code sample explaining how to do this properly? Because MQL5 spec says otherwise. Also my experince says otherwise: I'm using .NET libraries in multiple MQL5 projects and it works as expected in Windows 8.1/10/11.
What you will probably find is that the DLL is not detached from the terminating process.

I had been struggling with this issue with mysqlclient.dll and could figure out, strategy tester does not clean detach the DLL. Much more it seems Terminal is actually loading the DLL, and that's where it stays loaded.

Please do some research on this, because I cannot confirm on older client versions anymore, as they don't work as of today. Therefore I have currently no possibility to reproduce the issue from back then.
 
Dominik Christian Egert #:
What you will probably find is that the DLL is not detached from the terminating process.

I had been struggling with this issue with mysqlclient.dll and could figure out, strategy tester does not clean detach the DLL. Much more it seems Terminal is actually loading the DLL, and that's where it stays loaded.

Please do some research on this, because I cannot confirm on older client versions anymore, as they don't work as of today. Therefore I have currently no possibility to reproduce the issue from back then.
Shame on me. I figured out that .NET Framework was not properly installed on the Wine prefix where I run the Metatrader 5 terminal. After reinstalling it, the DLL problem was resolved.
Thanks for your help anyway!
WineHQ - .NET Framework 4.8
  • appdb.winehq.org
Open Source Software for running Windows applications on other operating systems.
 
WStranger #:
Shame on me. I figured out that .NET Framework was not properly installed on the Wine prefix where I run the Metatrader 5 terminal. After reinstalling it, the DLL problem was resolved.
Thanks for your help anyway!
Well, thank you for reporting back, I didn't know that.