问题
I have this code for MQL5.
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_plots 1
#import "Indicator\\..\\Libraries\\PythonConnect.dll"
int OnInit()
{
//---
return(INIT_SUCCEEDED);
}
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
//---
Print(PythonConnect1::TRENDFINDER());
//--- return value of prev_calculated for next call
return(rates_total);
}
I have created the PyhtonConnect.dll. But when I am running the code i am getting the following error:
2020.01.01 00:00:00 System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Python.Runtime, Version=2.5.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
2020.01.01 00:00:00 at PythonConnect.PythonConnect1.TRENDFINDER()
2020.01.01 00:00:00 --- End of inner exception stack trace ---
2020.01.01 00:00:00 at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
2020.01.01 00:00:00 at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
2020.01.01 00:00:00 at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
2020.01.01 00:00:00 at Wrapper.Wrapper.Call(MethodInfo method, Int64 owner, Int64 parameters, Int64 result)
2020.01.01 00:00:00 .Net runtime error
I am not getting the way to resolve it. I do not know why the file is not found, whereas it is placed inside the same folder where the PythonConnect.dll is placed.
Please somebody with dll experience let me know what might be the way to resolve it.
Also, to mention, I have tried #import "Indicators\\..\\Libraries\\Python.Runtime.dll"
. But still I am getting the same error.
来源:https://stackoverflow.com/questions/65003885/dependant-dll-loading-issue-in-mql5-from-c-sharp