dll import and use problem

 

Hi try to create a dll and import it , i store the dll inside a folderlibrary , the dll i have created with visualbasic.net and i call it with this code

//+------------------------------------------------------------------+
//|                                                da_cancellare.mq4 |
//|                                  Copyright 2023, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2023, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window

#import "testdll.dll"
    int Somma(int a, int b);
#import



int OnInit()
{
int risultato = Somma(5, 7);
Print("La somma di 5 e 7 è: ", risultato);


   return(INIT_SUCCEEDED);
}



but return me this error

2023.09.13 00:19:02.627    da_cancellare AUDCAD,H1: not initialized
2023.09.13 00:19:02.624    da_cancellare AUDCAD,H1: unresolved import function call
2023.09.13 00:19:02.508    Cannot find 'Somma' in 'testdll.dll'
why not import? thanks at all

 
faustf:

Hi try to create a dll and import it , i store the dll inside a folderlibrary , the dll i have created with visualbasic.net and i call it with this code

but return me this error

2023.09.13 00:19:02.627    da_cancellare AUDCAD,H1: not initialized
2023.09.13 00:19:02.624    da_cancellare AUDCAD,H1: unresolved import function call
2023.09.13 00:19:02.508    Cannot find 'Somma' in 'testdll.dll'
why not import? thanks at all

Please also share the DLL code, else we cannot help.
 

sorry  my visualbasic code for create  dll


Public Class Class1
    Public Function Somma(ByVal a As Integer, ByVal b As Integer) As Integer
        Somma = a + b
    End Function

End Class
 
faustf #:

sorry  my visualbasic code for create  dll


My guess here would be, you need to declare your exports in the visual basic project.

There should be some option available to create an export definition table. Maybe something with legacy compatibility or similar.

I hope someone else can clarify on the visual basic side.
 
i not belive is possible  in VB  i saw  this but is very complicated https://stackoverflow.com/questions/15111206/create-metatrader4-dll-with-vb-net,  i will try in c++
Create MetaTrader4 DLL with VB.Net
Create MetaTrader4 DLL with VB.Net
  • 2013.02.27
  • jlee88my jlee88my 2,935 21 21 silver badges 28 28 bronze badges
  • stackoverflow.com
I'm trying to create a DLL for MetaTrader4 with VB.Net. Most of the examples are in C++, but I know it can be done in VB.Net. I know it is a bit more tricky than C++. Can anyone point me in the right direction? something about defining MT4_EXPFUNC __declspec(dllexport)
 
faustf:

Hi try to create a dll and import it , i store the dll inside a folderlibrary , the dll i have created with visualbasic.net and i call it with this code

but return me this error

2023.09.13 00:19:02.627    da_cancellare AUDCAD,H1: not initialized
2023.09.13 00:19:02.624    da_cancellare AUDCAD,H1: unresolved import function call
2023.09.13 00:19:02.508    Cannot find 'Somma' in 'testdll.dll'
why not import? thanks at all

VB6.0,VB.net cannot build the standard DLL in general method.

last time i build stand dll using vb6 is on one day of 2004. and i had forgot the details so i am sorry about that.

try using vc++ instead.