I finally figure out how to do it. Although this is not the ideal solution, it works. I'm documenting here for "future-generations".
Basically, I'm using a program called DLLExporter.Exe that converts a managed .Net class method into a direct unmanaged function. It at:
http://www.codeproject.com/Articles/37675/Simple-Method-of-DLL-Export-without-C-CLI
Sample of my VB.Net code:
Imports System.Runtime.InteropServices
Public Class myFXTrader
<DllExporter.DllExport()>
Public Shared Function storeFXRatesIntoSQL(
<MarshalAsAttribute(UnmanagedType.LPWStr)> pvsBroker As String _
, <MarshalAsAttribute(UnmanagedType.LPWStr)> pvsSymbol As String _
, <MarshalAsAttribute(UnmanagedType.LPWStr)> pvsTimeStamp As String _
, pviAsk As Double _
, pviBid As Double) As <MarshalAsAttribute(UnmanagedType.LPWStr)> String
Dim vsErrorCode As String = ""
'---------------------------------
Try
'... do some work here ...
Catch ex As Exception
End Try
'---------------------------------
Return vsErrorCode
End Function
End Class
After compilation of the above code, I just run DLLExporter myFXTrader.dll
and it will do it's magic. The resulting .dll file can be copied to MT4's library folder and can be #import
and used. See sample Expert Advisor
code below:
#import "FXTrader.Exports.dll"
string storeFXRatesIntoSQL(string pvsBroker, string pvsSymbol, string pviTimeStamp, double pviAsk, double pviBid);
#import
int start()
{
Comment( storeFXRatesIntoSQL( AccountCompany(), Symbol(), TimeLocal(), Ask, Bid) );
int err;
err = GetLastError();
if(err>0) { Alert( err ); }
return(0);
}
Hope this will help whoever out-there who's attempting the same thing. I had to do quite a lot of reading/research to figure this out.