Discussion of article "How to Export Quotes from МetaTrader 5 to .NET Applications Using WCF Services" - page 2

 

recently saw another free way to program C# for MetaTrader
TradePlatform.NET
 
I'm currently trying to impliment my own c++ wrapper for my c# dll for mql5 interop. I have an issue with adding c# dll reference to my c++ library. Could you please clarify the following sentence "...add the CLR support, System.dll, QExport.dll, Qexport.Service.dll to the build reference". I was able to register my dll with regasm utility, add it to the gac and obtain a .tlb type definition file. My problem is I cannot find any #import or #include statements in the source code you provided. Your project seems to reference your dll libraries in some mysterious way. Could somebody please explain a proper way to add a reference to .NET dll to a c++ library? Even though it's not a purely mql5 question it directly relates to the article. I've been researching the topic for quite a while now and still cannot understand how a c++ library can have .NET dlls in its "External Dependencies" without any #import statements. This is my first encounter with c++ and so far it hasn't been a pleasant one, I even thought to convert the .dll to .lib and add a reference to it, but before I do anything I decided to seek advice from a COM specialist. I'm running Windows 8 Ultimate x64 and compile my c# dlls with VS2012 Ultimate. Please help the novice.
How to Exchange Data: A DLL for MQL5 in 10 Minutes
  • 2010.01.27
  • MetaQuotes Software Corp.
  • www.mql5.com
Now not so many developers remember how to write a simple DLL, and what are special features of different system binding. Using several examples, I will try to show the entire process of the simple DLL's creation in 10 minutes, as well as to discuss some technical details of our binding implementation. I will show the step-by-step process of DLL creation in Visual Studio with examples of exchanging different types of variables (numbers, arrays, strings, etc.). Besides I will explain how to protect your client terminal from crashes in custom DLLs.
 
Burton:

I'm currently trying to impliment my own c++ wrapper for my c# dll for mql5 interop. I have an issue with adding c# dll reference to my c++ library. Could you please clarify the following sentence "...add the CLR support, System.dll, QExport.dll, Qexport.Service.dll to the build reference". I was able to register my dll with regasm utility, add it to the gac and obtain a .tlb type definition file. My problem is I cannot find any #import or #include statements in the source code you provided. Your project seems to reference your dll libraries in some mysterious way. Could somebody please explain a proper way to add a reference to .NET dll to a c++ library? Even though it's not a purely mql5 question it directly relates to the article. I've been researching the topic for quite a while now and still cannot understand how a c++ library can have .NET dlls in its "External Dependencies" without any #import statements. This is my first encounter with c++ and so far it hasn't been a pleasant one, I even thought to convert the .dll to .lib and add a reference to it, but before I do anything I decided to seek advice from a COM specialist. I'm running Windows 8 Ultimate x64 and compile my c# dlls with VS2012 Ultimate. Please help the novice.
Quite stupidly I found I can reference c# dlls from c++ project by right clicking it and choosing References...  in the dialog box. There's so much crap out there on the web.
 
joeykruger:

I managed to get both this working with both 32bit MT5 and, after recompling for x64, managed to get it working with 64bit MT5....however, when I try to run the EA in the strategy tester they both crash spectacularly.

I would like to use this to export some price and indicator data into a database table to do some analysis with external software.....any ideas what could be causing this crash?   This is the closest I've come to a working solution so far.  


Joe

Hi Joe,

 Was there any special trick to get it working on x64? I've just compiled it for x64, but the dll crashes with weird errors on startup. 

 

Just posted a new job based on this article: https://www.mql5.com/en/job/34392 .

It's not working in my MT5 64 bits environment... 

Great article!

Thanks 

Freelance service at MQL5.com: Make Visual Studio 2012 solution downloaded from article work with Metatrader 5 64 bits
Freelance service at MQL5.com: Make Visual Studio 2012 solution downloaded from article work with Metatrader 5 64 bits
  • www.mql5.com
Hi, I'm a C# developer and downloaded the code from the article "HOW TO EXPORT QUOTES FROM METATRADER 5 TO .NET APPLICATIONS USING WCF SERVICES" ( https://www.mql5.com/en/articles/27 ). The problem is that my machine is a Windows 64 bits with MetaTrader 5 64 bits installed and I had to change the compile configurations to 64 bits in Visual Studio 2012. Ok, it compiled normally, then I added one new method that aims to return a string to MT5 which i called ReadBroker2MeInstructions . Compiled...
 

Just for knowledge, I discovered what happened in my 64 bits machine.

After hours and hours of researching and debugging, discovered that one referenced assembly was not loading, generating the exception "System.IO.FileNotFoundException: Unable to load file or assembly 'QExport.Service, Version=1.0.5771.13857, Culture=neutral, PublicKeyToken=56996a45dd1e337b'".

 Maybe because the dll has no config file, don't know yet, MT 5 did not know where to find the assembly. So it was trying to get it in the base path (path where metaeditor64.exe is located). After changing the output directory of the referenced projects to that path, worked as a charm.

 
sabe:

Hi Joe,

 Was there any special trick to get it working on x64? I've just compiled it for x64, but the dll crashes with weird errors on startup. 

Sabe, see my answer below.

[]'s