Status:
I've written a DLL
in C#, which is ment to be called from a code written in a MQL4
( basically a C-alike language ) and sends back some data ( unmanaged to managed and back ).
In general, the DLL
sends queries to a MySQL
-host and when needed, it returns back some data. I used the NuGet package "Unmanaged Exports".
I used this DLL
with the FOREX trading MetaTrader Terminal program, running on Windows 8.1 x64 and everything worked perfectly. The C# code was compiled in x86 since the MetaTrader Terminal runs only on x86.
Goal:
Now I am interested in using the same DLL
and call it using the same code but this time I need the code to run from a VPS.
This VPS runs on Windows Server 2008 R2 SP1 x64.
Other than that everything is the same:
same version of MetaTrader Terminal,
I even have installed VS 2013 ( same version as I used on my laptop ) on this VPS
and compiled the C# code with no problem.
I also installed Microsoft Visual C++ 2010 Redistributable, hoping this will help but I'm still here...
There is also no firewall which could be blocking the access to the host.
What could be preventing the DLL
to run on the VPS?
Thanks!!
Problem isolation:
I wrote a short C# program on the VPS in order to check the DLL
.
It ( DLL
) works great.
I know that the MetaTrader Terminal does recognize the DLL
because otherwise I would receive an error regarding that basic problem.
So the problem must be between the MetaTrader Terminal and the DLL
.
Based on inputs given,
a colision appears on otherwise working
MT4/DLL
cooperation scheme and out of question, a firewall is not to be blamed for.DLL
mechanics does not incorporate operations a firewall takes care about.So as to avoid any Win Server settings, that are on VPS typically out of your control,
move your
DLL
-file(s) into the safe-most location,recent changes to New-
MQL4.56789
have made a default location unsafe- so do not rely on placing the file right to the MT4 ~Terminal Directory~
/MQL4/Library
as you are used to on yourlocalhost
Beware the nested
DLL
callsLast resort
In case all efforts fail, a sure method to make a VPS-hosted solution work independently of the VPS-provider constraints and so as to minimise impacts from a risk of theirs potential non-reponsiveness, install the whole circus inside your-controlled VM ( typically a minimalistic wXP configured Virtual Guest Machine with the whole working solution, or you can "en-can" a working localhost installation ( not your whole notebook, but a test-machine ) )
The only adaptation needed then is the VPS-host installation of Hypervisor system ( VmWare WorkStation or a VM-Player ) plus a coordinated IP-adressing, which should not be an issue to match free IP-s/port#-s as needed.
How about a WINE thin-wrapped operations inside linux?
While tested and working smooth on Projects, I would not start with another approach alike linux/WINE thin-wrapped MetaTrader Terminal 4 operations ( which in facts embeds
.EXE
into aDLL
-abstraction served by non-Win O/S behind a surrounding crowd of WINE/linux adaptors ) because the primary task is to eliminate root source of DLL-collision(s).