文章 "使用非托管导出将 C# 代码运用到 MQL5" - 页 5

 
据我所知,RGiesecke UnmanagedExportLibrary 模板在某些地方使用了类似 // 代码这样的注释来解析 IL 文件。讲俄语的 Windows 用户会在其中插入 // Size 这样的俄语注释,这就是他的模板无法工作的原因。DLL 中根本没有函数,这就是错误 127 抛出的原因。很遗憾,仅仅为了这个模板,我不想改变 Windows 界面语言,尽管它工作得很好,而且似乎是正确的,至少 DLL 至少是卸载的。微软也是一把扫帚,你可以很容易地将数据从 C++ 转到 C#,但反过来就麻烦了。
 

我是64的win 8

用vs2013编译的

但是 可以加载了  但是  出现了 unresolved import function call

如何解决?

2014.03.05 20:39:59.220 UnmanagedExportsDLLExample1 (XAUUSD,H1) unresolved import function call

2014.03.05 20:39:59.220 UnmanagedExportsDLLExample1 (XAUUSD,H1) Cannot find 'Add' in 'Testme.dll'

 

2011.10.29 20:13:37    2000.01.03 00:00  Expert_NN_1_1 USDJPY,H1: cannot call function 'sum' from dll 'NN 1 DLL.dll' (error 127)

你好、

我也遇到了类似的错误。你是如何解决的?

2014.03.28 22:16:41.199 2014.03.25 23:59 未解决的导入函数调用

2014.03.28 22:16:41.199 2014.03.25 23:59 无法在 "Testme.dll "中找到 "Set2DArray"。

 
ANG3110:
据我所知,RGiesecke UnmanagedExportLibrary 模板...

这条留言是半年前留下的。之后有什么变化吗????

Автоматический трейдинг и тестирование торговых стратегий
Автоматический трейдинг и тестирование торговых стратегий
  • www.mql5.com
MQL5: язык торговых стратегий для MetaTrader 5, позволяет писать собственные торговые роботы, технические индикаторы, скрипты и библиотеки функций
 
除了这个功能,其他功能都能正常工作,有什么好主意吗?
 

方法一:

我是64的win 7,vs2012 C#。下载楼主的 testme.zip模板文件。

中间提示了几个错误(路径不对,文件丢失等之类的),已经解决了。

但最后,还是出现和和楼上同样的问题。不知道现在解决了没有?什么方法解决的。



方法二:

NuGet 安装的 RGiesecke包.

https://www.nuget.org/packages/UnmanagedExports/1.2.6

2013年11年最新的版本,提示

错误    2    C:\Users\Administrator\AppData\Local\Temp\tmp8B24\dllTest.il(58) : error : syntax error at token '{' in:   {
    dllTest



Unmanaged Exports (DllExport for .Net)
Unmanaged Exports (DllExport for .Net)
  • www.nuget.org
A set of compile-time libraries (nothing to deploy) and a build task that enable you to export functions from managed code to native applications. That means, you can create plugins in a managed language like C# or F# for native applications that only have a C-Api (like Notepad++). The nuget package is all you need. Just mark your methods with [DllExport] and build for x86, x64 or ia64. Hints: - You have to set your platform target to either x86, ia64 or x64. AnyCPU assemblies cannot export functions. - The export name defaults to the method name and the calling convention to stdcall. If that's all what you want, you can just use [DllExport] without parameters. - You cannot put your exports in generic types or export generic methods. (The CLR wouldn't know what type parameters to use)
[删除]  

您可以在 IJW 的帮助下使用 C++ stripper,然后纯粹通过编译器-链接器将所有内容合并为一个 DLL,不需要使用文章中描述的模板进行变态操作,这里有简要描述 -http://stackoverflow.com/questions/26226958/include-managed-c-sharp-dll-into-unmanaged-c-dll-all-in-one-single-file。

好吧,用 RGiesecke 模板描述的方法--这是一个黑客程序,迟早会停止工作,顺便说一句,我也没有工作......

但是,如果有人还想玩文章中描述的 IL 方法,还有一辆自行车,但它也不起作用 -https://github.com/winch/winch.pinkbile.com-c-sharp/tree/master/dll_tool/dll_tool。

Include managed C# DLL into unmanaged C++ DLL - all in one single file
Include managed C# DLL into unmanaged C++ DLL - all in one single file
  • stackoverflow.com
In comparison to the question above i need to combine DLLs so that final mixed DLL could export their functions to other unmanaged applications. For this i would like to compile them both as .netmodule and then combine them into one file with a linker so i have : 1) Libs - project with some library in C# - it does not have any dependencies...
 

你好、

有人能向 dll 发送包含字符串变量的结构吗?

我可以发送 int、double 和 float,但字符串变量却出现了这个错误:

Access violation read to 0x0000007B

这是我的 C# 结构:

        [StructLayout(LayoutKind.Sequential, Pack = 1)]
        public struct accInfo
        {
            public string broker;
// public String server;
            public int account;
// public String user;

            public double balance;
            public Double credit;
// public String currency;
            public int leverage;
            public int stopout;
            public int stopoutmode;
            public float commission;
            public int lotsize;
            public float minlot;
            public float lotstep;
            public float maxlot;
            public float gmtOffset;

// public String pair;
            public int digits;
            public int point;
            public int tradeAllowed;
            public int swaptype;
            public float swapbuy;
            public float swapsell;
            public int stoplevel;
        };

这里是 mql4 结构:

   struct accInfo
   {
      string   broker;
// string server;
      int      account;
// string user;
      
      double   balance;
      double   credit;
// string currency;
      int      leverage;
      int      stopout;
      int      stopoutmode;
      float    commission;
      int      lotsize;
      float    minlot;
      float    lotstep;
      float    maxlot;
      float    gmtOffset;
      
// 字符串对;
      int      digits;
      int      point;
      int      tradeAllowed;
      int      swaptype;
      float    swapbuy;
      float    swapsell;
      int      stoplevel;
   };

我试着将字符串变量编入结构,但 MT4 完全崩溃,没有任何错误,只是挂起并在窗口中崩溃。

       [StructLayout(LayoutKind.Sequential, Pack = 1)]
        public struct accInfo
        {
            [MarshalAs(UnmanagedType.LPWStr)]
            public string broker;
...

谢谢。

Discussion of article "Exposing C# code to MQL5 using unmanaged exports"
Discussion of article "Exposing C# code to MQL5 using unmanaged exports"
  • www.mql5.com
I also provided several examples on how to marshal MQL5 structures against C# and how to invoke exported DLL functions in MQL5 scripts. - Page 2 - Category: articles, library comments
 
Renat Fatkhullin:

是的,过段时间我们会写一篇关于使用动态链接库的新文章。那里已经添加了很多有趣的内容。

在此期间,您可以使用正在讨论的文章中的示例。这篇文章并不复杂。

还有 ...还要等多久?一年、两年...还是 10 年?

已经 3 年了。根据开头提到的文章,从dll导入 方法是不可能的。例子在哪里?

 

非常感谢这篇文章。我利用这里的想法为 C# 构建了这个开源 MQL 库。

https://github.com/jseparovic/MQL4CSharp

该库仍在开发中,目前尚未经过测试,但初步测试表明其想法是可行的。

它从 C# 发送命令的方式非常简单,使用线程让 C# 代码在其中运行,并使用 getters/setters 进行通信。MQL 每毫秒轮询一次等待命令,而 C# 代码可以阻塞直到写入结果。

请查看 https://github.com/jseparovic/MQL4CSharp/blob/master/MQL4CSharp/UserDefined/Strategy/MaCrossStrategy.cs,了解如何用 C# 实现策略。

干杯

杰森