I am not able to use any DLL

 

Hello!

I need to update my DLL because of changes in build 610. My old DLL and EA compiled before upgrade to 610 works fine in it. But I am not able to run even the simplest new expert + DLL now.

I am using Visual Studio 2010 and C#. DLL is compiled as 32bit.

Operating system: Windows 7 Prof 64bit

Here is my C# code:

using System.Runtime.InteropServices;
using RGiesecke.DllExport;

namespace C2DLLInvokeTest
{
    public class C2MT4DLLTEST
    {
        [DllExport("C2DLLTest", CallingConvention = CallingConvention.StdCall)]
        public static int C2DLLTest()
        {
            return 123;
        }
    }
}

This is my EA:

#property strict

#import "C2DLLInvokeTest.dll"
int C2DLLTest();
#import      

int OnInit()
  {
   Print("Hello");
   int result=C2DLLTest();
   return(INIT_SUCCEEDED);
  }

And here is my result:

MT4 EA + DLL

What can be a problem?

I am even not able to run the DLLSampleTester.mq4 included in installation. MT4 says: 'DLLSampleTester' is not expert and cannot be executed

I am sitting the whole day on it and I am really desperate.

Help me, please.

Bob

 
My first question would be how did you get MT4, originally before the upgrade, to read a managed code DLL?
 
Never mind. Just saw this line in code:using RGiesecke.DllExport;
 
nondisclosure:
Never mind. Just saw this line in code:using RGiesecke.DllExport;

Solved. I re-added the "UnmanagedExports Nuget package" and suddenly it works again.

Happy trading to all!

 

I have a similar problem using this approach but im calling a string function from c# to mt4 and its not working, it is working for int functions though.

[DllExport("testString", CallingConvention = CallingConvention.StdCall)]
public static string testString()
{
   return ("this is a test string");
}

in the terminal window it returns strange text "??????????g", I have all the correct references and my compiled dll and "RGiesecke.DllExport.Metadata.dll" in the \MQL4\Libraries\ folder, why is this not returning simple text back to mt4?

#import "mytest.dll"
   string testString();
#import
 

Found it, have to use this way:

 

[return: MarshalAs(UnmanagedType.LPWStr)]

        public static string mystring([MarshalAs(UnmanagedType.LPWStr)] string clearText)

        { ... }
Reason: