
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 hope RGiesecke will answer soon, you can track it at
http://stackoverflow.com/questions/4642548/how-to-use-a-net-assembly-in-delphi-without-registering-it-in-the-gac-or-com/5497058#5497058
*Huge* thanks for writing this article! It's very well written and the multitude of examples are extremely helpful.
The big hurdle for me was figuring out the variable types and how to pass them back and forth. (especially arrays and strings) It would be great to see some shared C# libraries for Metatrader. Once I learn more and build some useful libraries, I'll see if I can contribute them.
You have saved me a lot of time instead of learning by trial and error. Thanks for sharing your knowledge.
It's appreciated! :-)
Hi
I have a problem that suddenly (?) my DLL function returns error message "Cannot find 'Add' in 'TestMe.dll'. This is a simple example, using your code:
using System;
using System.Text;
using RGiesecke.DllExport;
using System.Runtime.InteropServices;
namespace Testme
{
class Test
{
[DllExport("Add", CallingConvention = CallingConvention.StdCall)]
public static int Add(int left, int right)
{
return left + right;
}
}
}
Using it in an .mql file:
#import "Testme.dll"
int Add(int left,int right);
#import
void OnStart()
{
//---
for(int i=0; i<3; i++)
{
Print(Add(i,666));
}
}
--> Cannot find 'Add' in 'Testme.dll'
Is there a change in how to call DLLs that I have missed?
Any opinion is greatly appreciated
Thomas
Hi
I also have a problem suddenly (it worked at first, but ...), when I compiled the sample dll, I got
Assembling 'C:\Users\internal228\AppData\Local\Temp\tmpAFBE\UELTest.x86.il' to DLL --> 'C:\Users\internal228\Documents\Visual Studio 2010\Projects\UnmanagedLibTest\UELTest\bin\Debug\x86\UELTest.dll'
Source file is UNICODE
***** FAILURE *****
UELTest
Anything I missed?
Windows 7; VisualStudio 2010;
Any opinion is greatly appreciated.
Risan
**UPDATE** Sorted it out thanks!
Hey there,
I followed the procedure entirely to write a dll in C# Express 2010. The template did not work so I manually added the dll files in a new project and everything compiled nicely (maybe I did something wrong here).
I wrote two easy functions just to test if it works, and I'm testing out of Metatrader 4. I get the following error:
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)
Any idea what might be the problem? The DLL is loaded my MT4, I checked, but it does not want to call the function. I noticed that this problem appears when trying to call a managed dll in MT4, but the procedure described in this article is supposed to solve the problem right?
Any help will be appreciated
Thanks!
Hi there,
Would just like to pass on my appreciation for such a well written article.
The site details for Robert Giesecke were invaluable.
I have learnt much. Not needing to write another C++ wrapper when I prefer VB.NET is a cool thing.
Many thanks.
Cheers,
Gordon
Hi,
I have the same problem.... methods I decorate are not found in mt5!!
pls help! (i'm using vs2010 and the template)
Published article How to open the world of C# from MQL5 by exporting unmanaged code:
Author: investeo
in the article https://www.mql5.com/en/articles/249 compiled dll of the author works in mt4 and mt5 correctly!
but when I try to create my own compiled dll from the source of the author (in VisualStudio 2010), this dll does not work (writes error 127)
all versions of .NET installed
// код C#
using System;
using System.Text;
using RGiesecke.DllExport;
using System.Runtime.InteropServices;
namespace TEST
{
class TEST
{
[DllExport("Add", CallingConvention = CallingConvention.StdCall)]
public static int Add(int left, int right)
{
return left + right;
}
}
}
namespace RGiesecke.DllExport
{
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
partial class DllExportAttribute : Attribute
{
public DllExportAttribute()
{
}
public DllExportAttribute(string exportName)
: this(exportName, CallingConvention.StdCall)
{
}
public DllExportAttribute(string exportName, CallingConvention callingConvention)
{
ExportName = exportName;
CallingConvention = callingConvention;
}
public CallingConvention CallingConvention { get; set; }
public string ExportName { get; set; }
}
}
// код МТ4
//+------------------------------------------------------------------+
#import "TEST.dll"
int Add(int a,int b);
#import
void start()
{
Comment(Add(3,2));
}
//+------------------------------------------------------------------+
and how to template to engage?
who knows where and how templates are inserted in c-sharp, the reason is apparently only this
and how to engage the template?
http://softblog.violet-tape.ru/2010/05/06/visual-studio-templates/
at the bottom for VS2010.
and useful information at the very bottom.