Managed (.NET) dll working from installation folder but not from terminal_data_directory\MQL4\Libraries - page 2
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I realise I'm a little late to the party here, but I just thought I'd share a tidier method of accomplishing this.
In the static constructor of the class that contains the [DllExport] methods, hook an event handler to AppDomain.CurrentDomain.AssemblyResolve - this will get called into every time the framework tries to resolve an external DLL reference.
Within this handler, you can split off the first part of the ResolveEventArgs.Name field to get the required DLL name, and then combine with Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) to get the full required DLL path to be used in conjunction with Assembly.Load
In this way, no extra method to set the MT4 library path is required, and no manual specification of DLLs to load using magic strings is required.
Can you give an example? Thanks.
//C#
string DLLpath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);See the latest and updated files attachment.
Copy MT4.DLL.Test.mq4 to \MQL4\Scripts\
Copy MT4.Test.dll and MT4.Utils.dll to \MQL4\Libraries\
Sample:
Here is some more info.
The problem occurs when the EA is calling DLL A which is calling another DLL B.
In this case only when the DLLs are in the installation folder it works as expected. But when the DLLs are in the libraries folder we get the exception.
Please find attached EA + c# projects
Thanks
did you find the solution to call dependant DLL file ? I ran into the the same problem. In my program, I'm trying to login Discord (the discord part works smoothly on regular C # app) using Discord.Net. but It gave me this result in the image. If I remove the Discord section, it runs smoothly. If you found the solution or anybody know how, please help me.
Thanks
my MQL5 program:
For anyone still struggling with this - this works for me:
Thank you @smimon and @roman5