Download MetaTrader 5
To add comments, please log in or register
Have you installed MetaTrader 5? Find out more about it!
Travis Silvers
162
Travis Silvers 2011.08.01 22:44 

I suspect this is a threading issue of some sort.

When using an Unmanaged C# Exported assembly and in that C# we access a static variable, over a few calls to OnTick I get an invalid pointer exception in Indicators.mqh line 302.

In C#:

private static int Sum { get; set; }
static UnmanagedExports(){ Sum = 0;}
[DllExport("Bug3AccessOfStaticVariableCausesThreadingIssues", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
static void Bug3AccessOfStaticVariableCausesThreadingIssues(int value)
{
    Sum += value;
}

 In an MQL Expert:

int OnInit()
{
   Bug3AccessOfStaticVariableCausesThreadingIssues(3);
}

 The only way I have found around this is to avoid static variable use in the external assembly and instead use a file.

Rashid Umarov
Admin
11805
Rashid Umarov 2011.08.02 12:03  
It may be more useful to write in the topic attched to this aricle

Travis Silvers
162
Travis Silvers 2011.08.02 19:07  

My problem isn't with the information in the article. I have a C# dll working just fine.

I have simply found some problems with how MT5 interacts with it that I have had to work around. I suspect these problems are MT5 issues and not C# issues so I thought I would see if anyone else has had them, can confirm etc.

Rashid Umarov
Admin
11805
Rashid Umarov 2011.08.03 15:57  
Get in touch with developers using Service Desk!
  • www.mql5.com
We therefore attach great importance to all user reports about issues in our programs and try to answer each one of them.
/
To add comments, please log in or register