Error connection mql5 and .Net SocketIOClient: Exception has been thrown by the target of an invocation.

 

Hello

I made .Net C# connection server and I made it dll file 

when i import a code in mql5 mettaTrader return this errors 

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException: Could not load file or assembly 'SocketIOClient, Version=3.1.0.0, Culture=neutral, or one of its dependencies. The system cannot find the file specified.
   at TcpConnection.socket.<ConnectToServer>d__0.MoveNext()
   at System.Runtime.CompilerServices.AsyncVoidMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
   at TcpConnection.socket.ConnectToServer()
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Wrapper.Wrapper.Call(MethodInfo method, Int64 owner, Int64 parameters, Int64 result)
.Net runtime error

this my c# code 

using System;
using SocketIOClient;
namespace TcpConnection
{
    public static class socket
    {
        public static async void ConnectToServer()
        {
            var client = new SocketIOClient.SocketIO("ws://127.0.0.1:8080");
            client.On("connection", response =>
            {
                Console.WriteLine(response);
                string text = response.GetValue<string>();
            });

            client.OnConnected += async (sender, e) =>
            {
                // Emit a string
                await client.EmitAsync("hi", "socket.io");

            };

            await client.ConnectAsync();
        }  
    }

}

and this is mql5 simple code to test it 

#import "TcpConnection.dll"

void OnStart()
{
    socket :: ConnectToServer();
    
}

if any one can help me 

Thanks

 
wesam kheer:

Hello

I made .Net C# connection server and I made it dll file 

when i import a code in mql5 mettaTrader return this errors 

this my c# code 

and this is mql5 simple code to test it 

if any one can help me 

Thanks

dont you need to import the connect to server function in the header ?

 
Lorentzos Roussos #:

dont you need to import the connect to server function in the header ?

no this the form about .Net it dont need import in the header

 
wesam kheer: namespace TcpConnection

Try it without the namespace. In the documentation example they don't use a namespace — Documentation on MQL5: Language Basics / Preprocessor / Importing Functions (#import)

 
wesam kheer:

Hello

I made .Net C# connection server and I made it dll file 

when i import a code in mql5 mettaTrader return this errors 

this my c# code 

and this is mql5 simple code to test it 

if any one can help me 

Thanks

The error says

The system cannot find the file specified.
I am guessing here, but this could be due to search path inclusions, and maybe you need to copy some additional DLLs into MQL5/Libraries folder.

DLLs are loaded on demand, and if they are not in local path, a search pattern is applied.

 
Dominik Egert #:
The error says

I am guessing here, but this could be due to search path inclusions, and maybe you need to copy some additional DLLs into MQL5/Libraries folder.

DLLs are loaded on demand, and if they are not in local path, a search pattern is applied.

I tried to upload the "SocketIOClient" inside MQL5/Libraries folder put still same error 

C# work correctly but i need the library because i need make Tcp socket connection