Sharing C++ DLL, C# DLL and EX5 among multiple EA/Service - page 2

 
Alain Verleyen #:

What "underlying ushort" ? You are working with a string if you want it in ushort you need to converted it (copy). You can use StringToShortArray() for that.

Use supported .NET version and you will avoid a lot of trouble. You should never rely on Metaquotes as you never know if and when they will add/fix what you want.

The performance bottleneck problem I described in this post:

https://www.mql5.com/en/forum/388556#comment_27648029

applies to all supported C# .DLL versions.

Could this be added to the Dev team to fix when you get around looking into C# .DLLs please? Thanks

I'll definitely use workaround in the mean time to minimize performance overhead. Note, this issue doesn't occur for C++ DLLs.
 
Alain Verleyen #:

What "underlying ushort" ? You are working with a string if you want it in ushort you need to converted it (copy). You can use StringToShortArray() for that.

Use supported .NET version and you will avoid a lot of trouble. You should never rely on Metaquotes as you never know if and when they will add/fix what you want.

Internally MQL5 uses ushort for each character in the string.

Forum on trading, automated trading systems and testing trading strategies

Sharing C++ DLL, C# DLL and EX5 among multiple EA/Service

bot, 2022.02.11 21:27

Tried both, still the strings are getting copied each time.

public static string SayGreeting(string name)
public static string SayGreeting(ref string name)


Note, I can get references passed for arrays of int, double etc, but not string. string is very critical to have good performance as it is always needed.

A question I have is, is it possible to get the ushort[] array for the MQL5 string?

A solution/hack would be to have  a C++ DLL as the bridge, that way you will have control over marshalling
since MQL5 is nicer to c++ dlls.

But since performance is critical, I would opt to just write the entire DLL in C++ and avoid the headache.
 
bot #:

The performance bottleneck problem I described in this post:

https://www.mql5.com/en/forum/388556#comment_27648029

applies to all supported C# .DLL versions.

Could this be added to the Dev team to fix when you get around looking into C# .DLLs please? Thanks

I'll definitely use workaround in the mean time to minimize performance overhead. Note, this issue doesn't occur for C++ DLLs.
Sorry I had not read the topic attentively and misunderstood your issue.