C# dll, error 127

 

I've gone through the forum posts and cannot figure out how to resolve error 127. I created a .def file but I'm not sure why or what to do with it... none of the samples even reference the file, although an earlier post discussed it resolving the issue.

Steps Taken:

1) Placed test2.mqh in experts\include

2) Placed test2.dll in experts\libraries (written in C#)

3) Run test2.mq4 from client terminal

Generates "2008.11.16 22:54:20 Test2 EURUSD,Daily: cannot call function 'SaySomething' from dll 'test2.dll' (error 127)" at runtime.

Files:
error127.zip  2 kb
 

Hi texasnomad,


try to store the DLL file in the windows\system32 directory

 

Just tried it... same error

 
texasnomad:

I've gone through the forum posts and cannot figure out how to resolve error 127. I created a .def file but I'm not sure why or what to do with it... none of the samples even reference the file, although an earlier post discussed it resolving the issue.

Steps Taken:

1) Placed test2.mqh in experts\include

2) Placed test2.dll in experts\libraries (written in C#)

3) Run test2.mq4 from client terminal

Generates "2008.11.16 22:54:20 Test2 EURUSD,Daily: cannot call function 'SaySomething' from dll 'test2.dll' (error 127)" at runtime.

Hello.

Dont you know you cant call managed code from mql4 directly?

You have to write unmanaged (c++ dll) wrapper that calls c# assembly functions.


So, you've got to:

1) Add COM inreface into your assembly.

2) Register this assembly (RegAsm.exe), create type library file .tpl

3) Write c++ wrapper.



Here is a helpful link http://blogs.msdn.com/deeptanshuv/archive/2005/06/26/432870.aspx


btw, i want to write an article describing this situation, but it will be in russan.

 
GarF1eld:

Hello.

Dont you know you cant call managed code from mql4 directly?


really?


How so? I never knew this was the case.

 
GarF1eld:

Hello.

Dont you know you cant call managed code from mql4 directly?

You have to write unmanaged (c++ dll) wrapper that calls c# assembly functions.


So, you've got to:

1) Add COM inreface into your assembly.

2) Register this assembly (RegAsm.exe), create type library file .tpl

3) Write c++ wrapper.



Here is a helpful link https://www.mql5.com/go?link=https://blogs.msdn.microsoft.com/deeptanshuv/2005/06/26/how-to-call-c-code-from-managed-and-vice-versa-interop/


btw, i want to write an article describing this situation, but it will be in russan.


Yes you can

 
skyhr:

really?


How so? I never knew this was the case.


You can call assemblies directly but you need to change the dll. I have it totally integrated into Visual Studio, if you want the details contact me.
Reason: